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

Scott Klein

"Professional LINQ"


ToArray
The ToArray operator creates an array from an IEnumerable sequence. You may remember from previous
chapters that the ToArray operator forces immediate execution of the query. In the following
example, ToArray is used to query the first names from the Person.Contact table and return the results
as an array:
DataContext context = new DataContext("Initial Catalog =
AdventureWorks;Integrated Security=sspi");
Table contact = context.GetTable();
var query = contact.Select(con => con.FirstName).ToArray();
foreach (string item in query)
listBox1.Items.Add(item);
75
Part I: Introduction to Project LINQ
The following lists partial results of running this query:
Gustavo
Catherine
Kim
Humberto
Pilar
Frances
Margeret
Carla
Jay
ToDictionary
The ToDictionary operator inserts all the elements returned in the sequence into a Dictionary(Of TKey,
TValue). The following example uses the ToDictionary operator to create and populate a Dictionary(Of
TKey, TValue)and then iterate through that dictionary to populate a list box.


Pages:
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6