Linq查询的性能是否有下面的LINQ查询的性能差异:与采取过滤
var query = from q in this.context.SomeTable
where q.SomeId == SomeId
select new SomeViewModel
{
PrimaryAttr = q.PrimaryAttr;
Attribute1 = q.Attribute1,
Attribute2 = q.Attribute2,
Attribute3 = q.Attribute3
};
query = query.OrderByDescending(q => q.PrimaryAttr).Take(5).ToList();
如果我过滤器首次在同一条直线上查询:
var query = (from q in this.context.SomeTable
where q.SomeId == SomeId
select new SomeViewModel
{
PrimaryAttr = q.PrimaryAttr;
Attribute1 = q.Attribute1,
Attribute2 = q.Attribute2,
Attribute3 = q.Attribute3
}).OrderByDescending(q => q.PrimaryAttr).Take(5).ToList();
为什么不试试? – HimBromBeere