How to use GroupBy in LINQ?
Ans. It is used for grouping of elements based on a specified value. Each group has a key. It returns a collection
of IGrouping<Key, Values>.
DataContext context = new DataContext();
var query=from ord in context. tblOrder
group ord by ord.CustomerID into grouping
select
new
{
grouping.Key,
grouping
};
Ans. It is used for grouping of elements based on a specified value. Each group has a key. It returns a collection
of IGrouping<Key, Values>.
DataContext context = new DataContext();
var query=from ord in context. tblOrder
group ord by ord.CustomerID into grouping
select
new
{
grouping.Key,
grouping
};
Comments
Post a Comment