与实体框架一致 - 订单,在哪里,跳过和拿走都没有效果

时间:2017-08-01 08:06:47

标签: c# entity-framework linq iqueryable

我正在使用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);

OrderByDescendingWhereSkipTake不会产生任何影响。

1 个答案:

答案 0 :(得分:2)

您没有使用查询结果

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);