我正在使用 .Take() 来获得固定数量的结果。
获得TotalCountBeforeTake
(即好像我没有使用.Take())的最佳方法是什么?
我可以在TotalCountBeforeTake
不运行两次查询的情况下获得吗?
var Results = (from results in db.FindWords(term)
orderby results.word
select results.word).Take(100);
//just to get the total record count
int TotalCountBeforeTake = (from results in db.FindWords(term)
select results.word).Count();
// only showing 100 out of TotalCountBeforeTake results,
// but in order to know the TotalCountBeforeTake I had to run the query twice.
foreach (var result in Results)
{
Console.Write(result.ToString());
}