© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
Morricore

❔ [EF Core] e => locationsIds.Any(id => e.Location.ParentsIds.Contains(id)); could not be translated

Expression type
Expression<Func<Sensor, bool>>
Expression<Func<Sensor, bool>>
where
Sensor
Sensor
has field
Location
Location
.
Location
Location
has string field
ParentsIds
ParentsIds
, containing bunch of
Location
Location
ID's.
Code:
            var locationsIds = locations.Select(e => e.Id.ToString()).ToList();
            return e => locationsIds.Any(id => e.Location.ParentsIds.Contains(id));
            var locationsIds = locations.Select(e => e.Id.ToString()).ToList();
            return e => locationsIds.Any(id => e.Location.ParentsIds.Contains(id));


Exception:
The LINQ expression 'id => EntityShaperExpression: 
    Domain.Location
    ValueBufferExpression: 
        ProjectionBindingExpression: Inner
    IsNullable: False
.ParentsIds.Contains(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 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
The LINQ expression 'id => EntityShaperExpression: 
    Domain.Location
    ValueBufferExpression: 
        ProjectionBindingExpression: Inner
    IsNullable: False
.ParentsIds.Contains(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 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.


upd. Found mention of mine issue.
https://stackoverflow.com/a/27295828
No solution
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ could not be translated
C#CC# / help
17mo ago
LINQ expression could not be translated after converting object
C#CC# / help
4y ago
EF Core
C#CC# / help
2y ago
EF Core not fetching sub-entities by Id [Answered]
C#CC# / help
4y ago