How to use Having in LINQ?
Ans. 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
};
Ans. 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
};
Comments
Post a Comment