SORU
29 Mart 2009, Pazar


SERİ - Tarafından Gruba Katıl, Sayım ve Sol

Hadi bu SQL de ki:

SELECT p.ParentId, COUNT(c.ChildId)
FROM ParentTable p
  LEFT OUTER JOIN ChildTable c ON p.ParentId = c.ChildParentId
GROUP BY p.ParentId

Nasıl SERİ bu SQL çevirebilir miyim? COUNT(c.çıkamadım Childıd), oluşturulan SQL her zaman çıkış COUNT (*) gibi. Şimdiye kadar neler bulduk:

from p in context.ParentTable
join c in context.ChildTable on p.ParentId equals c.ChildParentId into j1
from j2 in j1.DefaultIfEmpty()
group j2 by p.ParentId into grouped
select new { ParentId = grouped.Key, Count = grouped.Count() }

Teşekkür ederim!

CEVAP
29 Mart 2009, Pazar


from p in context.ParentTable
join c in context.ChildTable on p.ParentId equals c.ChildParentId into j1
from j2 in j1.DefaultIfEmpty()
group j2 by p.ParentId into grouped
select new { ParentId = grouped.Key, Count = grouped.Count(t=>t.ChildId != null) }

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Abbeydabby0277's channel

    Abbeydabby02

    9 ŞUBAT 2012
  • Rachel Raum

    Rachel Raum

    10 EYLÜL 2007
  • TheOtherMau5

    TheOtherMau5

    6 Mart 2012