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

Scott Klein

"Professional LINQ"

The reason for the mix of syntaxes in this example is that the GroupBy operator is not available
in query syntax.
This example also gives you an idea of the flexibility you have when using the standard query operators.
Concatenating Operator
Concatenating is the process of joining two objects together. In LINQ, concatenating joins two collections
into a single collection, and is accomplished via the Concat operator.
In the following example, contact last names are concatenated with CustomerIDs from the
Person.Contact table and Sales.SalesOrderHeader table:
DataContext context = new DataContext("Initial Catalog=@@ta
AdventureWorks;Integrated Security=sspi");
63
Part I: Introduction to Project LINQ
Table contacts = context.GetTable();
Table orders = context.GetTable();
var query = contacts.Select(con => con.LastName).Concat(orders.Select(order @@@ta
=> order.CustomerID.ToString()));
foreach (var item in query)
{
listBox1.Items.Add(item);
}
The results in the list box will first list all of the contacts??™ last names, followed by all of the CustomerIDs.


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