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
This filter works well with about 60 different entities, except for one entity: Rule, when retrieving this entity I get the exception:
The LINQ expression 'DbSet<Rule>\r\n .Where(r => __ef_filter__OwnedBookingSuppliers_1\r\n .Contains(r.Owner.Id))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information
I am wondering what is different with this entity that causes it not being able to evaluate the query server side since it´s a fairly simple query?
I am guessing that it is the fact that Rule is an abstract base class for a set of other entities that inherits Rule. In the modelbuilder I have no special configuration for Rule but there is configurations for descendants that look like this:
I am guessing that it is the fact that Rule is an abstract base class for a set of other entities that inherits Rule. In the modelbuilder I have no special configuration for Rule but there is configurations for descendants that look like this:
I'm guessing that Rule is an unmapped base type. Would this explain what is being seen?
r.Owner.Id seems to not getting expanded. My guess is r.Owner navigation is not getting expanded.
About not being mapped - There is DbSet in expression tree which comes from UserContext.OwnedBookingSuppliers means there is some DbSet. Plus, CompositeRule is in the model and a collection navigation property of Rules. Not sure if Rule is unmapped. But I could not create a runnable code based on pieces here.
Moved from discussion #22162
Question
From @andrejohansson
I have a set of entities, whom all fulfill an interface IOwnedEntity
These entities get a query filter applied to them:
This filter works well with about 60 different entities, except for one entity:
Rule
, when retrieving this entity I get the exception:I am wondering what is different with this entity that causes it not being able to evaluate the query server side since it´s a fairly simple query?
I am guessing that it is the fact that Rule is an abstract base class for a set of other entities that inherits Rule. In the modelbuilder I have no special configuration for Rule but there is configurations for descendants that look like this:
Relevant parts of rule:
A class referencing rules can look like this:
Does anybody know the cause? or can anybody give me hints on how to debug this so that I can learn why it´s failing to translate?
Replies
From @smitpatel
Can you share a stand-alone repro?
From @ajcvickers
@smitpatel Based on this:
I'm guessing that Rule is an unmapped base type. Would this explain what is being seen?
From @smitpatel
r.Owner.Id seems to not getting expanded. My guess is r.Owner navigation is not getting expanded.
About not being mapped - There is DbSet in expression tree which comes from UserContext.OwnedBookingSuppliers means there is some DbSet. Plus, CompositeRule is in the model and a collection navigation property of Rules. Not sure if Rule is unmapped. But I could not create a runnable code based on pieces here.
From @andrejohansson
Managed to get this to work, but the error threw me of a bit. I had made two errrors:
Once I fixed these things worked out for me.
The text was updated successfully, but these errors were encountered: