I have a query :
select siniflar.id,siniflar.sinif,count(ogrenciId)
from siniflar
left join oda
on siniflar.id=oda.sinifId
where siniflar.ogretmenid=2
group by siniflar.id,siniflar.sinif
And this is my conversion to Linq:
from snf in db.siniflar
join oda in db.oda
on snf.id equals oda.sinifId
where snf.ogretmenid==oID
group oda by new
{
snf.id,snf.sinif
} into g
select new
{
sinifIDsi=g.Key.id,
sinifADi=g.Key.sinif,
Column1 = g.Count()
})
I want the result of empty count's too but I can't adapt left or right join to linq with group by. DefaultIfEmpty() method is not working. Can anyone help me?