員工是一個示例實體類型。LINQ - 最小化返回記錄 - 正確寫出這些表達式的方式
var r1 = (from c in _ctx select c).Skip(5).Take(5);
// my intent is to pull the first record from the query
var r2 = (from c in _ctx select c).FirstOrDefault<Employee>();
// my intent is to pull the last record from the query.
// any good way to ask for the result back in the reverse
// order of the natural sort without specifing a field/property name?
var r3 = (from c in _ctx select c).LastOrDefault<Employee>();
這些操作是否拉回整個記錄(對象)然後過濾? 什麼是寫這些以便整行是LINQ表達式的最好方法是什麼?
寫一個只迭代一次的foreach循環?也許保留一個內部計數器。 – 2010-01-15 16:04:44
你有遠程源嗎?!?! (LINQ to SQL) http://msdn.microsoft.com/en-us/library/bb399410.aspx – salgo60 2010-01-15 16:10:08
salgo60,是的,現在是LINQ to SQL表達式。以後可能是LINQ to Entities。 – BuddyJoe 2010-01-15 16:18:04