我可以知道IEnumerable
(或IQueryable
)的延期評估是否已經發生?也就是說,是否曾經調用過GetEnumerator().MoveNext()
。有沒有辦法?如何判斷IEnumerable是否已經過評估?
我如何在以下示例中編碼HasBeenEvaluated()
?
private void Example()
{
IEnumerable<Thing> things = _Repository.GetObjects<Thing>();
bool x = HasBeenEvaluated(things); // returns false
foreach (var thing in things)
{
x = HasBeenEvaluated(things); // returns true
}
}
http://stackoverflow.com/questions/19518859/how-to-determine-if-an-ienumerable-has-been-evaluated – Habib 2015-04-02 15:34:53
also http://stackoverflow.com/questions/9624805/is-it-possible-to - 確定-IF-AN-ienumerablet-HAS-deffered-正在執行中 – Habib 2015-04-02 15:35:24