mihies wrote:
Hi Frans,
Here is repro case suggested by DX folk:
var stdGouped = from c in ctx.Customers.ToArray() group c by 0 into cc select cc.Count(); var stdResult = stdGouped.ToArray();
var bugGouped = from c in ctx.Customers group c by 0 into cc select cc.Count(); var bugResult = bugGouped.ToArray();
The later yields exception Object reference not set to an instance of an object.
I see, but what does the query mean? When I run it through linq to sql I get a bogus query:
SELECT COUNT(*) AS [value]
FROM (
SELECT @p0 AS [value]
FROM [dbo].[Customers] AS [t0]
) AS [t1]
GROUP BY [t1].[value]
-- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [0]
This is a very complicated way of doing:
(from c in ctx.Customers select c).Count();
or better:
IQueryable variable.Count()
The main problem is that the value to group on isn't from INSIDE the query, yet it's supplied as a parameter, i.e. the '0' value.
This isn't supported by LLBLGen Pro, because it makes no sense: you specified a PK field, so it should group on that field instead of a constant. (however grouping is redundant here, it can just do a count).
I've gone to great lengths implementing group by, on multiple fields (with anonymous typed objects), however this scenario is new to me (and as it has an easy alternative, I don't see why one would implement it like this).
About the first problem: the ObjectID is used always (at least I think so now) when one sets KeyExpression to an invalid property (CustomerID instead of CustomerId in my case).
Ok, so that's their problem then. I still don't see why they would opt for that property, but perhaps that's a glitch in their code, not sure.