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

Scott Klein

"Professional LINQ"


List quantity = new List {99, 48, 120, 73, 101, 81, 56};
int cnt = quantity.Count;
listbox1.items.add(cnt);
When run, this query returns 7. In the following example, the Count operator is used to count the number
of items for the specified sales order.
var query =
from od in orderdetail
where od.SalesOrderID == 43662
select od.UnitPrice;
listbox1.Items.Add(query.Count());
When this query is executed, the list box contains the value of 22, meaning that there are 22 items for the
specified order.
You can also specify a criterion for the Count operator. Here??™s an example in which the Count operator is
applied but given a condition, where the unit price is less than 200.
var query =
from od in orderdetail
where od.SalesOrderID == 43662
select od;
listbox1.Items.Add(query.Count(orderDetail => orderDetail.UnitPrice < 200));
65
Part I: Introduction to Project LINQ
LongCount
The LongCount operator, which returns an Int64 (a 64-bit integer), is used to count the number of elements
in a large collection??”one with more than Int32.


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