Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
select a.Name, Count(b.Id)
from Table1 a
inner join Table2 a on a.Id = b.Id
Group by  a.Name, b.Id


What I have tried:

var result = (from a in Table1IQurable
				join b in Table2IQurable on a.Id equals b.Id 
				select new NewTable
				{
				 Name = a.Name,
				 CountNo = b.count()
				 }).ToList();
Posted
Updated 1-Jun-20 20:29pm

1 solution

Your original SQL uses Group by - why not also use the linq group by if you want the same results?
See here: Group query results (LINQ in C#) | Microsoft Docs[^]
 
Share this answer
 
Comments
Maciej Los 2-Jun-20 2:55am    
;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900