请帮我将下面的 MSSQL 转换为 LINQ。
SELECT A.id, A.type, COUNT(IIf(B.BookId IS NOT NULL, 0, null)) AS TotalCount
FROM Store A
LEFT JOIN Book B ON A.id = B.id
GROUP BY A.id, A.type;
我目前有这个 LINQ 代码:
from a in Store
join b in Book on a.id equals b.id into c
from d in c.DefaultIfEmpty()
group a by new
{
a.id,
a.type
} into g
select new
{
StoreId = g.Key.id,
StoreType = g.Key.type,
TotalCount = g.Key !=null?g.Count():0
}
我想我错过了一些重要的东西。