You can use static methods on all generated entity collection types to get aggregate information. Notice this functionality allows you to get information with advanced filtering with 1-line of code.

//Get the count
int count = CustomerCollection.GetCount(x => x.City == "Berlin");

//Get the Average
decimal? average = OrderDetailCollection.GetAverage(x => x.UnitPrice, x => x.UnitPrice < 50);

//Get the Min
decimal? minimum = OrderDetailCollection.GetMin(x => x.UnitPrice, x => x.UnitPrice < 50);

//Get the Max
decimal? maximum = OrderDetailCollection.GetMax(x => x.UnitPrice, x => x.UnitPrice < 50);

//Get Global Max (whole table, no filter)
maximum = OrderDetailCollection.GetMax(x => x.UnitPrice);

	//Get Global Count (whole table, no filter)
	count = CustomerCollection.GetCount();

Last edited Sep 11, 2009 at 9:32 AM by codetools, version 2

Comments

No comments yet.