空我有这样的方法:值不能在LINQ条款
protected async Task<List<T>> Get<T>(Expression<Func<T, bool>> select) where T : class, IEntity
{
var query = Context.Set<T>();
query = query.Where(select);
return await query.ToListAsync<T>();
}
我这样称呼它:
var result = await Get<T>(a => a.Id == myId);
但Get方法不断抛出“值不能为空。参数:source'。
我错过了什么?
更新1:
StackTrace: at System.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName) at System.Data.Entity.QueryableExtensions.ToListAsync[TSource](IQueryable'1 source) at SoccerPool.MVC5.Models.Config.BaseApiController.<Get>d__49'1.MoveNext() in c:\Projects\SoccerPool\SoccerPool.MVC5\Models\Config\BaseApiController.cs:line 190
更新2:
Context.Set<T>() is not null. It contains 48 records if I don't perform the linq query. And 'Context' is a property which returns an instance of my DbContext.
您可以添加堆栈跟踪吗? –
你能解释一下你如何填充'Context.Set()',因为错误提示'query'为空 –
jaywayco