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
{{ message }}
Repository navigation
'AS' in group by statement when an 'AS' is present in the select statement #11218
Emploi
{
public int EmployeurId {get; set;}
public Employeur Employeur {get;set;}
...
}
Employeur
{
public int Id {get; set;}
public string NomCourt {get;set;}
...
}
EF uses Emploi.EmployeurId instead of Emploi.Employeur.Id which is ok. It renames it in the query with 'AS' statement. The problem is that the statement get copied in the group by clause with the 'AS' in it.
emploiQuery
.GroupBy(e => new { e.Employeur.Id, e.Employeur.NomCourt })
.Select(grp => new { Value = grp.Key.Id, Label = grp.Key.NomCourt, Count = grp.Count() })
This generates the following query:
SELECT [e].[EmployeurId] AS [Id], [e.Employeur].[NomCourt], COUNT(*)
FROM [Emploi] AS [e]
INNER JOIN [Employeur] AS [e.Employeur] ON [e].[EmployeurId] = [e.Employeur].[Id]
GROUP BY [e].[EmployeurId] AS [Id], [e.Employeur].[NomCourt]
Activity
Query: Improvements to Relational GroupBy translation for composition
Query: Improvements to Relational GroupBy translation for composition
Query: Improvements to Relational GroupBy translation for composition
Query: Improvements to Relational GroupBy translation for composition
Query: Improvements to Relational GroupBy translation for composition