yv989c/BlazarTech.QueryableValues

QueryableValues fails when joining against a query that uses the Include method

yv989c opened this issue ยท 2 comments

yv989c commented

As reported in #30 (comment)

When materializing the query, it fails with a System.InvalidOperationException exception:

Unable to translate a collection subquery in a projection since either parent or the subquery doesn't project necessary information required to uniquely identify it and correctly generate results on the client side. This can happen when trying to correlate on keyless entity type. This can also happen for some cases of projection before 'Distinct' or some shapes of grouping key in case of 'GroupBy'. These should either contain all key properties of the entity that the operation is applied on, or only contain simple property access expressions.
yv989c commented

๐Ÿ‘‹ @fiseni, this has been fixed in the latest version, which is already deployed to NuGet.

fiseni commented

That's great ๐Ÿ‘

I see you've added int field as key, and also you're ordering by that key. So, this is the difference.

Generated query on 7.2.0

SELECT [c].[Id], [c].[Name]
FROM [Customers] AS [c]
INNER JOIN (
  SELECT TOP(@p1) [V] FROM OPENJSON(@p0) WITH ([V] uniqueidentifier '$', [_] BIT '$._') ORDER BY [_]
) AS [b] ON [c].[Id] = [b].[V]

Generated query on 7.3.0

SELECT [c].[Id], [c].[Name]
FROM [Customers] AS [c]
INNER JOIN (
  SELECT TOP(@p1) [X], [G]
  FROM OPENJSON(@p0) WITH ([X] int, [G] uniqueidentifier)
  ORDER BY [X]
) AS [b] ON [c].[Id] = [b].[G]

I tested the includes too, everything works fine. Awesome!