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

'AS' in group by statement when an 'AS' is present in the select statement #11218

Closed
yepeekai opened this issue Mar 9, 2018 · 0 comments
Closed
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. regression type-bug
Milestone

Comments

@yepeekai
Copy link

yepeekai commented Mar 9, 2018

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]
@ajcvickers ajcvickers added this to the 2.1.0 milestone Mar 9, 2018
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 12, 2018
smitpatel added a commit that referenced this issue Mar 13, 2018
- Add support for translating OrderBy after GroupBy operator
- Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870
- Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157
- GroupBy Aggregate works when key/element/result selector is DTO instead of anonymous type Resolves #11176
- Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218

Part of #10012
smitpatel added a commit that referenced this issue Mar 14, 2018
- Add support for translating OrderBy after GroupBy operator
- Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870
- Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157
- GroupBy Aggregate works when key/element/result selector is DTO instead of anonymous type Resolves #11176
- Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218
- Translate GroupBy Constant/Parameter with aggregates Resolves #9969

Part of #10012
smitpatel added a commit that referenced this issue Mar 14, 2018
- Add support for translating OrderBy after GroupBy operator
- Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870
- Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157
- GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated)
- Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218
- Translate GroupBy Constant/Parameter with aggregates Resolves #9969

Part of #10012
Part of #2341
smitpatel added a commit that referenced this issue Mar 14, 2018
- Add support for translating OrderBy after GroupBy operator
- Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870
- Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157
- GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated)
- Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218
- Translate GroupBy Constant/Parameter with aggregates Resolves #9969

Part of #10012
Part of #2341
smitpatel added a commit that referenced this issue Mar 14, 2018
- Add support for translating OrderBy after GroupBy operator
- Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870
- Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157
- GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated)
- Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218
- Translate GroupBy Constant/Parameter with aggregates Resolves #9969

Part of #10012
Part of #2341
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview2, 2.1.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. regression type-bug
Projects
None yet
Development

No branches or pull requests

3 participants