How to use Having in LINQ?

There is no having operator in LINQ, but you can get the same result by using a Where clause after a Group By clause.

DataContext context = new DataContext();
var q = from ord in context.tblOrder group ord by ord.CustomerID into grouping where grouping.Count() >= 2 select new {
	grouping.Key, grouping
};

 

Tagged , . Bookmark the permalink.

Leave a Reply