Inhalte aufrufen

Profilbild

Multiple DBContext join

LINQ

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
2 Antworten zu diesem Thema

#1 nguyen si phong

nguyen si phong

    Newbie

  • Members
  • Punkt
  • 9 Beiträge

Geschrieben: 25 April 2019 - 12:39

Hello.
I'm having a problem:

When I create a new plugin with MyObjectContext. and use the query:
var query = from mT to _myPluginRepository.Table
            join bp into _blogPostRepository.Table on mT.BlogPostId equals bp.Id
            select mT;

var results = new PagedList <MyPluginEntity> (query, pageIndex, pageSize);
An error has occurred:
The specified LINQ expression contains references to queries that are associated with different contexts.
System.InvalidOperationException: The operation can not be completed because the dbContext has been disposed.
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext ()
   at System.Data.Entity.Internal.InternalContext.Initialize ()
   at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute [TResult] (expression expression)
   at System.Linq.Queryable.Count [TSource] (IQueryable`1 source)
   at SmartStore.Core.PagedList`1.EnsureIsLoaded () in E: \ .. \ SmartStore.Core \ PagedList`T.cs: line 56
   at SmartStore.Core.PagedList`1.GetEnumerator () in E: \ .. \ SmartStore.Core \ PagedList`T.cs: line 341
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext ()
   at System.Linq.Buffer`1..ctor (IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray [TSource] (IEnumerable`1 source)
 

I need help.
Thanks.

 


  • Stephennuh gefällt das

#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 25 April 2019 - 17:40

Unfortunately not supported by Entity Framework.


Marcus Gesing

Smartstore AG


#3 nguyen si phong

nguyen si phong

    Newbie

  • Members
  • Punkt
  • 9 Beiträge

Geschrieben: 26 April 2019 - 03:32

Thanks for your support.
I will build on another option.