var projects = _projectRepo.FindAll(x => listProjectIds.Any(u => u == x.Id)).ToList();
// .FindAll() return IQueryable<T>
// listProjectIds as a List<Guid>()
在调试
时显示以下错误System.InvalidOperationException: 'The LINQ expression 'u => (Guid?)u == EntityShaperExpression:
DataApp.Entities.Project
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.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.'
请帮我解决这个问题!
将Any
改为Contains
:
var projects = _projectRepo
.FindAll(x => listProjectIds.Contains(x.Id))
.ToList();