I try to convert this query syntax:
res = from co in db.SALES
join
op in db.OPERATORS
on co.ID_OP equals op.ID
where co.DATA_CLOSE == null
group new { co, op } by new { op.ID, op.NAME } into g
select new
{
ID = g.Key.ID,
NAME= g.Key.NAME,
COUNT = g.Select(x => x.co).Count()
};
to method syntax:
res= db.OPERATORS.GroupJoin(
db.SALES.Where(c=>c.DATA_CLOSE==null),
op => op.ID,
co => co.ID_OP,
(co, grp) =>
new
{
NAME= co.NAME,
COUNT = grp.Select(x=>x.ID ).Count()
});
first query works as expected,just like inner join,I got only operators with opened sales count second give me ALL operators with opened sales count,if there is no opened sale,it give me 0, how to make second query to work like the first one
thanks
Join!=GroupJoin!=GroupBy. Converting a working query to a different syntax make no sense to me. Good luck.