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

Scott Klein

"Professional LINQ"

AsQueryable().SelectMany(own => own.Pets);
When this code is run, it produces the following:
Yukon
Fido
Killer
Fluffy
Spike
Tinkerbell
This same example could be written follows:
var query =
from o in owners
select o;
foreach (var pet in query.SelectMany(own => own.Pets))
listbox1.Items.Add(pet);
56
Chapter 4: LINQ Standard Query Operators
Restriction Operator
where is the restriction operator. It applies filter criteria on the sequence. The values of the sequence are
filtered based on a supplied predicate.
The where operator does not initiate the execution of the query. The query is executed when enumeration
over the object is initiated, at which point the filter is applied. Here??™s an example that applies a filter to
the query expression, filtering the results so that only those contacts whose first name begins with the
letter S are returned:
IEnumerable query =
from c in contact
where c.FirstName.StartsWith("S")
select new {c.FirstName, c.LastName, c.EmailAddress}
This example could also be written using method syntax as follows:
var query =
contact.


Pages:
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6