Skip to content

Using ToString (or similar) on projection of a joined Key ID in GroupBy causes the wrong table reference to be used #1982

Open
@gliljas

Description

@gliljas

A query like this:

var result = db.OrderLines
    .GroupBy(x => new {x.Order.OrderId,x.Order.OrderDate})
    .Select(x => new { OrderIdString = x.Key.OrderId.ToString(), x.Key.OrderDate, Count=x.Count() })
    .ToArray();

where the grouping is done on a join and the projection uses ToString on the Id, results in

select cast(order1_.OrderId as nvarchar(50))

and

group by orderline0_.OrderId

One of these uses the wrong table. I think it could be argued that it's the "group by" which choses the wrong table/column, but that would be a bigger change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions