I migrate a site ASP.NET MVC to ASP.NET MVC core, with EF to EF Core.
I make a request with empty value :
var q = bd.Prod
.Where(o => o.xxx == yyy)
.GroupBy(o => o.sss)
.Select(g => new
{
ccc = g.Key,
vvv = g.Sum(i => i.qqq),
bbb = g.Sum(i => i.fff),
nnn = g.Sum(i => i.ggg),
});
When I execute this code with EF return null when all cell of sum are empty. But EF Core return 0 when all cell of sum are empty. How to make EF Core return null ?
GroupBy
in memory (so called client evaluation), and this is known behavior of LINQ To ObjectsSum
implementation. Wait for EF Core v.2 to get that eventually fixed.null
s. Thenull
s are discarded, and what remains is an empty set, but that's not the only possible reasonable behaviour when faced withnull
.NotSupported
exceptions :)ISNULL(SUM(...), 0)
just to make the behaviour match L2O's. Client evaluation is already something you can disable in EF Core.