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

Scott Klein

"Professional LINQ"

MaxValue elements. You use LongCount the same way
you use the Count operator, as shown in the following example:
List quantity = new List {99, 48, 120, 73, 101, 81, 56};
Int64 cnt = quantity.LongCount();
listbox1.items.add(cnt);
Now count the number of items in an order:
var query =
from od in orderdetail
where od.SalesOrderID == 43662
select od.UnitPrice;
listbox1.Items.Add(query.LongCount());
And here??™s the example specifying a specific condition:
var query =
from od in orderdetail
where od.SalesOrderID == 43662
select od;
listbox1.Items.Add(query.LongCount(orderDetail => orderDetail.UnitPrice < 200));
Max
The Max operator returns the maximum value within a sequence. Like the Average operator, Max works
on many data types, including decimals, integers, and doubles.
The following example returns the maximum value from the list of provided integers:
List quantity = new List {99, 48, 120, 73, 101, 81, 56};
int cnt = quantity.Max();
listbox1.items.add(cnt);
The value returned is 120. This operator can also be applied to the following example, which returns the
maximum unit price of all the items for a specific order.


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