i have table
id pagenane username
i want this sql query
select pagename, count(*) as num from pagestat where username='name' group by pagename
how can i do it by linq?
i have table
id pagenane username
i want this sql query
select pagename, count(*) as num from pagestat where username='name' group by pagename
how can i do it by linq?
Well, try this:
var query = from row in context.pageStat
where row.UserName == "name"
group row by row.PageName into g
select new { PageName = g.Key, Count = g.Count() };
var retVal = (from s in dataContext.YourTable where
s.UserName.Equals("name")
group s by s.PageName into k
select new {PageName = k.Key, Count = k.Count() }).ToList();