#29: Linq Breaking Deferred Execution.

If you need your Linq Query to be executed Immediately after construction,we can use Conversation Operators like ToList(),ToArray().They force the query to execute immediately

var item = new List<int>();
item.Add(2);
IEnumerable<int> result = item.Select(x =>; x*5).ToList();
//Query is Executed Immedialtely and result will be 10.
//No deferred Execution,because we used ToList(),Forcing query to execute immediately
item.Add(3);
foreach (var VARIABLE in result)
{
 Console.WriteLine(VARIABLE);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s