Aggregate functions are functions that aggregate (add, average, calculate maximum or minimum, or count) the elements in a collection. Unlike normal queries, aggregations pass all items in the collection to an aggregate function that calculates all items, but treats them as a batch.
LINQ queries always start with the From clause—except those that aggregate collections. To run an aggregation of a collection, start the LINQ query with the Aggregate clause instead with the From clause, as shown in the examples in this section.
This first example aggregates the product list into a total, apparently calculating the total sales of articles:
Sub AggregateDemo() Dim feignedSales = Aggregate artElement In prdList Into TotalSum = Sum(artElement.UnitPrice) ...