AwonDanag AwonDanag - 7 months ago 40 Question

Simple SQL Count to LINQ?

I've spent the last two hours or so researching this. Is new to LINQ btw.
How do I get an SQL like this to a LINQ query?

SELECT, name, designation, COUNT(
FROM region r
LEFT JOIN area a on a.region_id =
GROUP BY, name, designation

My alternative of course is to place this in a
(which I can figure out) but I'd like this to be added to my knowledge. Thanks!

P.S. Either VB or C# will do but I'd prefer the former.


I think it would be like this:

var result =
            from r in regions
            join a in areas on equals a.region_id into subvalues
            from _ in subvalues.DefaultIfEmpty()
            select new { id =, name =, designation = r.designation, count = subvalues.Count() };