我遇到了异步任务的问题,该任务从具有特定条件的数据库中获取项目 当我调用ToListAsync()时,我收到此错误
类型'System.Collections.Generic.IAsyncEnumerable
1[System.Guid]' cannot be used for constructor parameter of type 'System.Collections.Generic.IEnumerable
1 [System.Guid]'的表达式 参数名称:arguments [0]
这是代码段:
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
我将不会收到错误,并且一切正常。