我想将代码转换为异步代码,但转换类型时出错,如何将代码转换为异步代码?
public IQueryable<MyProject.Models.Campaign> Where(System.Linq.Expressions.Expression<Func<MyProject.Models.Campaign, bool>> predicate)
{
try
{
return db.Campaigns.Where(predicate);
}
catch
{
return null;
}
}
答案 0 :(得分:-1)
我找到了解决方法,问题是我不得不将IQueryable更改为IList。
public async Task<IList<MyProject.Models.Campaign>> WhereAsync(System.Linq.Expressions.Expression<Func<MyProject.Models.Campaign, bool>> predicate)
{
try
{
return await db.Campaigns.Where(predicate).ToListAsync();
}
catch
{
return null;
}
}