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 37 | Next

Scott Klein

"Professional LINQ"

The select query
operator falls into the category of projection operators, and performs a projection over a sequence, an
object that implements the IEnumerable for a given type. In this case, the select operator enumerates
the source sequence of first names.
select fn;
The where query operator is of the restriction operator type??”in fact, it is the only operator of that type.
Just like T-SQL, the LINQ where operator filters a sequence. In the preceding example, it filters the
sequence by limiting the results returned to only those whose name begins with the letter S.
where fn.StartsWith("S")
If you are trying this example out yourself, create a new Windows Forms project and place a list box on
the form. In the Load event of the form, place the following code:
string [] firstnames = { "Scott", "Steve", "Ken", "Joe", "John",
"Alex", "Chuck", "Sarah"};
11
Part I: Introduction to Project LINQ
IEnumerable val = from fn in firstnames
where fn.StartsWith("S")
select fn;
foreach (string name in val)
{
listbox1.Items.Add(name);
}
Press F5 to run the app.


Pages:
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6