Skip to content

Query: Cross join with table having TPH mapping causes discriminator to be ignored producing incorrect results #8375

Closed

Description

@maumar

Comparing_entities_using_Equals_inheritance

                var query = from g in ctx.Gears
                            from o in ctx.Gears.OfType<Officer>()
                            where g.Equals(o)
                            orderby g.Nickname
                            select new { Nickname1 = g.Nickname, Nickname2 = o.Nickname };

produces:

SELECT [g].[Nickname] AS [Nickname1], [o].[Nickname] AS [Nickname2]
FROM [Gear] AS [g]
CROSS JOIN [Gear] AS [o]
WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (([g].[Nickname] = [o].[Nickname]) AND ([g].[SquadId] = [o].[SquadId]))
ORDER BY [Nickname1]

discriminator predicate for Officer in the second collection is being ignored so we return too many results

Activity

  1. added this to the 2.0.0 milestone on May 5, 2017
  2. changed the title [-]Query: incorrect results returned for some queries with cross product and inheritance/predicate[/-] [+]Query: Cross join with table having TPH mapping causes discriminator to be ignored producing incorrect results[/+] on May 5, 2017
  3. smitpatel commented on Jun 23, 2017

    @smitpatel
    Contributor

    #8094 would fix this too.

  4. modified the milestones: 2.0.0, Backlog on Jun 29, 2017
  5. modified the milestones: 2.1.0, Backlog on Sep 7, 2017
  6. 15 remaining items

  7. removed their assignment
    on Sep 1, 2018
  8. self-assigned this
    on Sep 4, 2019
  9. modified the milestones: Backlog, on Sep 4, 2019
  10. modified the milestones: , 3.0.0 on Sep 9, 2019
  11. smitpatel commented on Sep 9, 2019

    @smitpatel
    Contributor

    Fixed in #17724

  12. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions