You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECTCOALESCE(SUM(CASEWHEN ([u].[UserType] <>2) AND ([c].[SettlementType] =2) THEN [b].[Amount]
END), 0.0) AS [CashPayment], COALESCE(SUM(CASEWHEN [c0].[SettlementType] =1THEN [b].[Amount]
END), 0.0) AS [CreditPayment]
FROM [Books] AS [b]
INNER JOIN [User] AS [u] ON [b].[CreatorUserId] = [u].[Id]
INNER JOIN [User] AS [u0] ON [b].[OwnerUserId] = [u0].[Id]
LEFT JOIN [Corporation] AS [c] ON [u0].[CorporationId] = [c].[Id]
LEFT JOIN [Corporation] AS [c0] ON [u].[CorporationId] = [c].[Id]
GROUP BY [b].[Kind]
Check the last join ([c0] not used in any 'ON' part):
LEFT JOIN [Corporation] AS [c0] ON [u].[CorporationId] = [c].[Id]
[c] used instead!!!
Also I think second left join is useless totally in this query.
So the query result will be wrong (The result will multiply by [Corporation] counts)
I'm trying to migrate a project to EF core. but it is a silent error that can not found without check the query result manually.
So its blocked my way.
SELECTCOALESCE(SUM(CASEWHEN ([u].[UserType] <>2) AND ([c].[SettlementType] =2) THEN [b].[Amount]
END), 0.0) AS [CashPayment], COALESCE(SUM(CASEWHEN [c].[SettlementType] =1THEN [b].[Amount]
END), 0.0) AS [CreditPayment]
FROM [Books] AS [b]
INNER JOIN [User] AS [u] ON [b].[CreatorUserId] = [u].[Id]
INNER JOIN [User] AS [u0] ON [b].[OwnerUserId] = [u0].[Id]
LEFT JOIN [Corporation] AS [c] ON [u0].[CorporationId] = [c].[Id]
GROUP BY [b].[Kind]
Include provider and version information
EF Core version: 6.0.1
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 6.0)
Operating system: Windows 10
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered:
First Check Generated SQL Script:
Check the last join ([c0] not used in any 'ON' part):
LEFT JOIN [Corporation] AS [c0] ON [u].[CorporationId] = [c].[Id]
[c] used instead!!!
Also I think second left join is useless totally in this query.
So the query result will be wrong (The result will multiply by [Corporation] counts)
I'm trying to migrate a project to EF core. but it is a silent error that can not found without check the query result manually.
So its blocked my way.
The Models
The DbContext
The Query
Expected Query
Include provider and version information
EF Core version: 6.0.1
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 6.0)
Operating system: Windows 10
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered: