Search⌘ K
AI Features

Deferred and Immediate Execution

Explore the concepts of deferred and immediate execution in LINQ. Understand how queries run only when accessed or execute instantly to capture data snapshots. This lesson helps you manage when and how your LINQ queries evaluate data sources for efficient programming.

We'll cover the following...

The timing of LINQ query execution depends on how the query is evaluated. There are essentially two ways of executing a LINQ query:

  • Deferred execution: The LINQ query only executes when we try to address an item from a resulting collection.

  • Immediate execution: The LINQ query executes immediately after construction.

Let us explore these concepts in detail.

Deferred execution

There are three steps to creating and running a LINQ query:

    ...