c# - how to use group by in the following linq query -
c# - how to use group by in the following linq query -
i m beginner in linq syntax , need write linq query. themes , dataset_meta tables joined id , theme columns in respective tables , need count of each theme used in dataset_meta table.
the next sql gives me require in linq
select t.themename , count(dm.id) 'theme count' dbo.themes t inner bring together dbo.dataset_meta dm on t.id=dm.theme grouping t.themename
i have started next unable finish it
from theme in datacontext.themes bring together dataset_meta in datacontext.dataset_meta on theme.id equals dataset_meta.theme select new { }
found solution. hope helps someone.
from theme in datacontext.themes bring together dataset_meta meta in datacontext.dataset_meta on theme.id equals meta.theme grouping theme new {theme.themename,theme.id} grp select new { name = grp.key, count = grp.count() };
c# linq entity-framework
Comments
Post a Comment