Sunday, 16 December 2012

Obtaining the Maximum value in a list or Collection using Linq

In order to retrieve the highest value of a column in a list of collection, Linq offers a handy method to achieve this;

Dim maxUnitsInStock = Aggregate prod In db.Products _
                      Into Max(prod.UnitsInStock)

Simple!

No comments:

Post a Comment