为什么我在使用
this.QQYALIEntities.Set<T>().Where(o => o.Id > 3000).OrderByDescending(o => o.CreateTime).ToList();
生成的SQL语句是
select * FROM [dbo].[Content] AS [Extent1] WHERE [Extent1].[Id] > 3000 ORDER BY [Extent1].[CreateTime] DESC
而使用
Func<Content, bool> whereFunc = o => o.Id > 3000; Func<T, object> orderFunc = o => o.CreateTime; this.QQYALIEntities.Set<T>().Where(whereFunc).OrderByDescending(orderFunc).ToList()
这样的查询方式,会出现全表查询,是不是where实现机制不一样,有没有好的解决方案?
要用表达式树:Expressions<Func<Content, bool>>
园子里的参考博文: