【发布时间】:2016-02-02 22:02:10
【问题描述】:
我有一个 C# 和实体框架项目。我需要将 Repository 的一些方法转换为 Async。我在转换此方法时遇到问题,不确定我可以使用什么来代替 Where 子句。
public async Task<IEnumerable<Product>> GetProductByYearIdAsync(int yearId)
{
return await ApplicationsContext.Product.Where(product=> product.YearId == yearId);
}
当我使用它时,它给了我无法等待 iQueryable 的错误。当我使用 FirstOrDefaultAsync 时,我知道如何转换为 IEnumerable。
【问题讨论】:
标签: c# entity-framework asynchronous