Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-202

Allow direct entity comparison

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Many providers allow direct entity comparisons, specifically these are:

      .Where(e => e != null)

      At the top level this is effectively .Where(true)

      .Where(e => e == null)

      At the top-level this effectively is .Where(false)

      .Where(e => e == f)

      At the top-level this is effectively key comparisons.  e.g. Where(e => e.Id == f.Id)

      .Where(e => e != f)

      At the top-level this is effectively key comparisons.  e.g. Where(e => e.Id != f.Id)

      Solution

      We should probably just match any direct comparisons to the key which will handle all these scenarios as well as odd ones like .Where(e => e > f) if EF doesn't prevent that.

      Open questions

      1. Do we want to support owned entity comparisons? They don't have real keys so we'd have to do full-property comparisons which would be different from the top-level comparisons here and may match multiple entities as there is no ref integrity.

            Assignee:
            Unassigned Unassigned
            Reporter:
            damien.guard@mongodb.com Damien Guard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: