【发布时间】:2018-11-02 17:46:03
【问题描述】:
我有一个异步任务的问题,该任务从数据库中获取具有特定条件的项目 当我调用 ToListAsync() 时出现此错误
“System.Collections.Generic.IAsyncEnumerable
1[System.Guid]' cannot be used for constructor parameter of type 'System.Collections.Generic.IEnumerable1[System.Guid]”类型的表达式 参数名称:arguments[0]
这是代码sn-p:
public async Task<IEnumerable<Parent>> GetItems(List<Guid> TypeIds)
{
var items = context.Parent.Include(x => x.Child).Where(x => new HashSet<Guid>(x.Child.Select(y => y.TypeId).Distinct()).SetEquals(new HashSet<Guid>(TypeIds)));
return await items.Include(x=> x.Child).ToListAsync();
}
如果我实现这个方法不是async 我不会得到错误并且一切正常。
【问题讨论】:
-
你不能拥有像实体框架那样的
Wherelambda。
标签: c# asynchronous entity-framework-core ef-core-2.0