Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Daniel Solis - Illustrated C# 2010 - 2010.pdf
Скачиваний:
16
Добавлен:
11.06.2015
Размер:
11.23 Mб
Скачать

CHAPTER 21 INTRODUCTION TO LINQ

Query Continuation

A query continuation clause takes the result of one part of a query and assigns it a name so that it can be used in another part of the query. Figure 21-12 shows the syntax for query continuation.

Figure 21-12. The syntax of the query continuation clause

For example, the following query joins groupA and groupB and names the join groupAandB. It then performs a simple select from groupAandB.

static void Main()

{

var groupA =

new[] { 3, 4, 5, 6 };

 

var groupB =

new[] { 4, 5, 6, 7 };

 

var someInts

= from a in groupA

 

 

join b in groupB on a equals b

← Query continuation

 

into groupAandB

 

from c in groupAandB

 

 

select c;

 

foreach (var

a in someInts)

 

Console.Write("{0} ", a);

}

This code produces the following output:

4 5 6

563

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]