SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 79 | Next

Scott Klein

"Professional LINQ"


So what does typically mean? There are two types of query execution: deferred and immediate. In most
cases you want to use deferred; however, there are cases when immediate execution is necessary.
34
Chapter 3: LINQ Queries
The following sections discuss these types and when the use of each is appropriate.
Figure 3-1
Deferred Execution
So far all the examples in this book have shown deferred query execution, which executes the query only
when you start to loop through the query variable, such as in a foreach loop.
For instance, the following code loops through the variable val, which contains the query expression
taken from the earlier string array example:
foreach (string name in val)
{
Console.WriteLine(name);
}
Deferred execution is appropriate when returning a sequence (multiple values). Because the query (and
variable) don??™t ever contain the query results, you are free to execute (iterate over) this query over
and over again with little overhead.
Immediate Execution
Any LINQ query that returns a single value is executed immediately.


Pages:
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6