When using QueryTrackingBehavior.NoTracking, Empty BSON collections do not result in empty CLR collections

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 9.0.4, 8.3.4
    • Affects Version/s: 9.0.3
    • Component/s: None
    • None
    • 🔵 Done
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      When NoTracking is used, empty BSON collections result in null CLR collections.

      Previous closed bug which fixed behaviour for tracked queries: https://jira.mongodb.org/browse/EF-105

      To reproduce, change the following tests to use NoTracking:

      db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
      1. OwnedEntity_non_nullable_collection_is_empty_when_empty
      2. OwnedEntity_nullable_collection_is_empty_when_empty

       

      I believe the following code should also be executed when using NoTracking (entry == null) to fix the issue:

      https://github.com/mongodb/mongo-efcore-provider/blob/main/src/MongoDB.EntityFrameworkCore/Query/Visitors/MongoProjectionBindingRemovingExpressionVisitor.cs#L606-L610

       

            Assignee:
            Damien Guard
            Reporter:
            Dan Hughes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: