Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GroupJoin does not correctly translate resultSelector to SQL. #7416

Closed
Dixin opened this issue Jan 15, 2017 · 1 comment
Closed

GroupJoin does not correctly translate resultSelector to SQL. #7416

Dixin opened this issue Jan 15, 2017 · 1 comment

Comments

@Dixin
Copy link

Dixin commented Jan 15, 2017

GroupJoin does not translate resultSelector correctly:

var leftOuterJoin = adventureWorks.Products.GroupJoin(
    inner: adventureWorks.Transactions,
    outerKeySelector: product => product.ProductID,
    innerKeySelector: transaction => transaction.ProductID,
    resultSelector: (product, transactions) => new
    {
        Name = product.Name,
        ActualCosts = transactions.Select(transaction => transaction.ActualCost)
    });

The projection is specified in the resultSelector.

In EF, the required 2 columns (and the key and a null identifier) are queried, which is correct:

SELECT 
    [Project1].[ProductID] AS [ProductID], 
    [Project1].[Name] AS [Name], 
    [Project1].[C1] AS [C1], 
    [Project1].[ActualCost] AS [ActualCost]
    FROM ( SELECT 
        [Extent1].[ProductID] AS [ProductID], 
        [Extent1].[Name] AS [Name], 
        [Extent2].[ActualCost] AS [ActualCost], 
        CASE WHEN ([Extent2].[ProductID] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1]
        FROM  [Production].[Product] AS [Extent1]
        LEFT OUTER JOIN [Production].[TransactionHistory] AS [Extent2] ON ([Extent2].[TransactionType] IN (N'P',N'S',N'W')) AND ([Extent1].[ProductID] = [Extent2].[ProductID])
    )  AS [Project1]
    ORDER BY [Project1].[ProductID] ASC, [Project1].[C1] ASC

However, in EF Core, all columns of both tables are queried:

SELECT 
[product].[ProductID], 
[product].[ListPrice], 
[product].[Name], 
[product].[ProductSubcategoryID], 
[product].[RowVersion], 
[transaction].[TransactionID], 
[transaction].[ActualCost], 
[transaction].[ProductID], 
[transaction].[Quantity], 
[transaction].[TransactionDate], 
[transaction].[TransactionType]
FROM [Production].[Product] AS [product]
LEFT JOIN [Production].[TransactionHistory] AS [transaction] ON [product].[ProductID] = [transaction].[ProductID]
ORDER BY [product].[ProductID]

It seems the resultSelector is not translated.

@maumar
Copy link
Contributor

maumar commented Jan 17, 2017

dupe of #6647

@maumar maumar closed this as completed Jan 17, 2017
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants