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

Scott Klein

"Professional LINQ"

SalesOrderID == 43662
select od.UnitPrice;
listbox1.Items.Add(query.Min());
The value returned from this query is 178.5808. The query can also be written like this:
var query =
from od in orderdetail
where od.SalesOrderID == 43662
select od;
listbox1.Items.Add(query.Min(orderDetail => orderDetail.UnitPrice));
Again, there??™s no performance advantage between the two queries. It??™s just a matter of preference
and readability.
Sum
The Sum operator calculates the sum of the selected values within a collection. It also works on many data
types, such as decimal, integers, and doubles.
The following example returns the sum of the given values from the list of provided integers:
List quantity = new List {99, 48, 120, 73, 101, 81, 56};
int cnt = quantity.Sum();
listbox1.items.add(cnt);
67
Part I: Introduction to Project LINQ
The value returned from this example is 578. Here??™s an example that returns the sum of the unit prices
for all the items for a specific order:
var query =
from od in orderdetail
where od.SalesOrderID == 43662
select od.


Pages:
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6