SalesOrderID == 43662
select od.UnitPrice;
foreach (decimal num in query.Distinct())
listbox1.Items.Add(num);
Without the trailing decimal places, you get the following results:
178
183
356
419
874
2146
69
Part I: Introduction to Project LINQ
Union
The Union operator returns the unique elements from the results of a union of two sequences or collections.
It is different from the concat operator in that it returns unique values, and the concat operator
returns all values.
The following example contains two lists (or data sources) that contain integer values. These lists do not
contain duplicate values. The Union operator is applied; it joins the two lists and returns only the unique
value in the resultset.
int[] numbers1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} ;
int[] numbers2 = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} ;
IEnumerable
union = numbers1.Union(numbers2);
foreach (int num in union)
listBox1.Items.Add(num);
The results from this query return the numbers 1 through 20. The next example also contains two lists of
numbers, but numbers that exist in the first list also exist in the second list, and the first list also contains
duplicate numbers (such as the numbers 1 and 9).
Pages:
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144