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