【发布时间】:2020-07-08 15:39:17
【问题描述】:
使用 Entity Framework Core 3.1 我有以下查询:
var ids = new List<Int32> { 1, 2, 3 };
users = context.Users
.Where(x => ids.All(y => x.UserSkills.Any(z => y == z.SkillId)));
var result = await users.ToListAsync();
当我运行此查询时,我收到以下错误:
'The LINQ expression 'DbSet<User>
.Where(u => True && __ids_0
.All(y => DbSet<UserSkill>
.Where(u0 => EF.Property<Nullable<int>>(u, "Id") != null && EF.Property<Nullable<int>>(u, "Id") == EF.Property<Nullable<int>>(u0, "UserId"))
.Any(u0 => y == u0.SkillId)))' 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()
我该如何解决这个问题?
【问题讨论】:
标签: entity-framework-core entity-framework-core-3.1