c# - Linq Query Count and GroupBy -


can tell me how sql query in linq?

select [id], count(*) [data].[dbo].[mytable] group [id] 

you can try approach:

 var res = ctx.mytable  // start table     .groupby(r => r.id) / group key of choice     .select( g => new {id = g.key, count = g.count()}) // create anonymous type w/results     .tolist(); // convert results list 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -