Reputation: 1703
I want express sql below by linq
select catalog,queryname,COUNT(*) from doctemplatecells group by catalog,queryname
I don't know how to get count(*), thanks
Upvotes: 1
Views: 92
Reputation: 77364
Every group consists of it's key (catalog, queryname) and it's elements as represented by the IEnumerable<>
implementation of the group.
So if you have a group as a result of LinQ, you can call the extension method Count()
on it.
var groups = doctemplatecells.GroupBy(dtc => new { Catalog = dtc.catalog, QueryName = dtc queryname });
foreach(group in groups)
{
console.WriteLine("{0} {1} #{2}", group.Key.Catalog, group.Key.QueryName, group.Count());
}
Upvotes: 2