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

Scott Klein

"Professional LINQ"

Title, emp.HireDate, cust.AccountNumber}
Each additional join associates a new table or data source with the results of the previous join.
The first example could also be written using method syntax as follows:
var query =
contact.Join(employee, con => con.ContactID,
emp => emp.ContactID, (con, emp) => new
{ Contact = con.FirstName, Employee} );
GroupJoin
The GroupJoin operator joins each value or element from the primary (first or left) data source with a set
of corresponding values from the secondary (right) data source. This type of join comes in handy when
you want to create a hierarchical data structure.
The following example uses GroupJoin to create a hierarchical structure from two different data
sources. The first data source lists motocross race teams, and the second data source lists the riders for
each of those teams. The GroupJoin operator is used join the two data sources together and produce an
output that lists the team and their associated riders.
List teams = new List{ new Team { name = "Yamaha"},
new Team { name = "Honda"} ,
new Team { name = "Kawasaki"} ,
new Team { name = "Suzuki"}} ;
List riders = new List {
new Rider { name = "Grant Langston", TeamName = "Yamaha"},
new Rider { name = "Andrew Short", TeamName = "Honda"},
new Rider { name = "James Steward", TeamName = "Kawasaki"},
new Rider { name = " Broc Hepler", TeamName = "Yamaha"},
new Rider { name = "Tommy Hahn", TeamName = "Honda"},
60
Chapter 4: LINQ Standard Query Operators
new Rider { name = "Tim Ferry", TeamName = "Kawasaki"},
new Rider { name = " Chad Reed", TeamName = "Yamaha"},
new Rider { name = "Davi Millsaps", TeamName = "Honda"},
new Rider { name = "Ricky Carmichael", TeamName = "Suzuki"},
new Rider { name = "Kevin Windham", TeamName = "Honda"}};
var teamsandriders = teams.


Pages:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6