You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using EF code first, I worked with detached entities and for updating my entities I used GraphDiff (that works with detached entities), so when I want to load my entities I use AsNoTraking():
_uow.Repository<WorkCenterCapacity>()
.FindAllQueryable()
.Where(/*some criteria*/)
.GroupBy(x => x.WorkCenter.Code)
.AsNoTracking()
.ToDictionary(x => x.Key, x => x.FirstOrDefault());
//do some changes
// update using graphDiff
It worked correctly and I was be able to update my detached entity using graphDiff.
But, recently I used LINQKit to use Predicate in my query so I changed above query to:
_uow.Repository<WorkCenterCapacity>()
.FindAllQueryable()
.Where(workCenterListCriteria) //predicate
.AsExpandable() //<----------- this line cause AsNoTracking doesn't work
.GroupBy(x => x.WorkCenter.Code)
.AsNoTracking()
.ToDictionary(x => x.Key, x => x.FirstOrDefault());
//do some changes
// update using graphDiff
but now when graphDiff wants to update the loaded WorkCenterCapacity entity I get following Error:
A first chance exception of type 'System.InvalidOperationException' occurred in RefactorThis.GraphDiff.dll
Additional information: GraphDiff supports detached entities only at this time. Please try AsNoTracking() or detach your entites before calling the UpdateGraph method
So it seems that AsExpandable cause AsNotracking doesn't work.
The text was updated successfully, but these errors were encountered:
Try to call AsNoTracking first, then AsExpandable. If i remember correctly, AsNoTracking casts the current query to some Entity Framework internal class, which cannot work since it's wrapped by AsExpandable...
I'm using EF code first, I worked with detached entities and for updating my entities I used GraphDiff (that works with detached entities), so when I want to load my entities I use
AsNoTraking()
:It worked correctly and I was be able to update my detached entity using graphDiff.
But, recently I used LINQKit to use
Predicate
in my query so I changed above query to:but now when graphDiff wants to update the loaded
WorkCenterCapacity
entity I get following Error:So it seems that
AsExpandable
causeAsNotracking
doesn't work.The text was updated successfully, but these errors were encountered: