IQueryable with Entity Framework - order, where, skip and take 无效
IQueryable with Entity Framework - order, where, skip and take have no effect
我正在使用 Entity Framework(代码优先),如下所示:
IQueryable<StammdatenEntityModel> query = dbSet;
query.OrderByDescending(s => s.CreateDateTime);
query.Where(s => s.Deleted == false);
if(!String.IsNullOrEmpty(keyword))
{
query.Where(s => s.SerialNumber.Contains(keyword)); //simplified for SO
}
query.Skip(skip);
query.Take(take);
但是 OrderByDescending
、Where
、Skip
和 Take
没有任何效果。
您没有使用查询结果
IQueryable<StammdatenEntityModel> query = dbSet;
query = query.OrderByDescending(s => s.CreateDateTime);
query = query.Where(s => s.Deleted == false);
if(!String.IsNullOrEmpty(keyword))
{
query = query.Where(s => s.SerialNumber.Contains(keyword)); //simplified for SO
}
query = query.Skip(skip);
query = query.Take(take);
我正在使用 Entity Framework(代码优先),如下所示:
IQueryable<StammdatenEntityModel> query = dbSet;
query.OrderByDescending(s => s.CreateDateTime);
query.Where(s => s.Deleted == false);
if(!String.IsNullOrEmpty(keyword))
{
query.Where(s => s.SerialNumber.Contains(keyword)); //simplified for SO
}
query.Skip(skip);
query.Take(take);
但是 OrderByDescending
、Where
、Skip
和 Take
没有任何效果。
您没有使用查询结果
IQueryable<StammdatenEntityModel> query = dbSet;
query = query.OrderByDescending(s => s.CreateDateTime);
query = query.Where(s => s.Deleted == false);
if(!String.IsNullOrEmpty(keyword))
{
query = query.Where(s => s.SerialNumber.Contains(keyword)); //simplified for SO
}
query = query.Skip(skip);
query = query.Take(take);