#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>();
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
foreach (var VARIABLE in result)

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 )

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