when I used to use EF 2.2 it rans this code without problems:
var resource = locResRepo.GetWhere(i => i.ForApplication.ToLower() == applicationName.ToLower())
.Where(resourcesConditionExpression)
.Select(item => new ResourceKeyObject
{
Id = item.Id,
ResourceKey = item.ResourceKey,
ResourceKeyValues = item.ActualLocalizationTranslation
.Where(translationConditionExpression)
.Select(v => new ResourceKeyValues
{
Language = v.Language,
KeyValue = v.Value
}).ToList()
}).ToList();
But now it throws error:
System.InvalidOperationException: Processing of the LINQ expression '(MaterializeCollectionNavigation(
navigation: Navigation: LocalizationResources.ActualLocalizationTranslation,
subquery: (NavigationExpansionExpression
Source: DbSet<ActualLocalizationTranslation>
.Where(a => EF.Property<Nullable<int>>(l, "Id") != null && EF.Property<Nullable<int>>(l, "Id") == EF.Property<Nullable<int>>(a, "ResourceId"))
PendingSelector: a => (NavigationTreeExpression
Value: (EntityReference: ActualLocalizationTranslation)
Expression: a)
)
.Where(i => EF.Property<Nullable<int>>((NavigationTreeExpression
Value: (EntityReference: LocalizationResources)
Expression: l), "Id") != null && EF.Property<Nullable<int>>((NavigationTreeExpression
Value: (EntityReference: LocalizationResources)
Expression: l), "Id") == EF.Property<Nullable<int>>(i, "ResourceId")))
.Where(t => True)' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) and so on.....
And I really cant realize why.. Or maybe I know something, but i don't know, how to implement it
Well I found out a solution. Before select must be .ToList() because of EF 3.1 logic
Starting with 3.0, EF Core LINQ queries are no longer evaluated on the client. learn more: MSDN
Actually i think your problem may be in i.ForApplication Property if it makes some calculations.