Geeks With Blogs
Abhishek Anand Bits & Bytes about .net technology framework. December 2013 Entries
Deferred Execution Vs Eager Loading
Lets start with an Example :int[] listOfNumbers = new int[] { 5, 9, 8, 1, 7, 3, 6, 4, 2, 0 }; int i = 0; var query = from num in listOfNumbers select ++i; // Note, the local variable 'i' is not incremented until each element is evaluated (as a side-effect): foreach (var x in query) { Console.WriteLine("x = {0}, i = {1}", x, i); } Now without deferred execution we would expect that after the variable “query” is declared, “i” would have the value 10 and the output would be: “x = {1-10}, i = 10” However ......

Posted On Tuesday, December 3, 2013 2:41 PM

Copyright © Abhishek Anand | Powered by: GeeksWithBlogs.net