I am using .net core 3 with ef. When I use the below code, result is loaded
DbSet<User>().Where(User =>User.UserRoleMapping.Any(UserRoleMapping => UserRoleMapping.RoleID == (int)1))
?
But when I use predicate inside the where clause of dbset rather than an expression, here’s the error encountered
The LINQ expression 'DbSet().Where(u => User.UserRoleMapping.Any(UserRoleMapping => UserRoleMapping.RoleID == 1))' 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.
Looks like the Any(), Contains() and all the helper methods are not getting translated to server execution due to limitation in Core 3.0 onwards, client side translation is restricted to top level projection only.
Is there any way I can progress with predicate without running into any problem.
Any insights?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…