[CSHARP-2158] Incorrect $unwind query when using SelectMany in subobjects Created: 27/Jan/18  Updated: 28/Oct/23  Resolved: 30/Jan/19

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.5
Fix Version/s: 2.8.0

Type: Bug Priority: Critical - P2
Reporter: Ivan Artemov Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-2046 consecutive SelectMany calls always r... Closed

 Description   

For SelectMany in subobjects, driver generate wrong unwind query

We have 2 objects:

public class Mention
    {
        [BsonRepresentation(BsonType.ObjectId)]
        public string Id { get; set; }
       
        public RelatedData Related { get; set; }
    }
 
    public class RelatedData
    {
        public List<int> Players { get; set; }
        public List<int> Clubs { get; set; }
    }

And we have query:

_context.For<Mention>().AsQueryable()
               .Where(...)
               .SelectMany(x => x.Related.Players)
               .ToList()

For this query driver generate :

{  "$match" : {  ....  }  },
{  "$unwind" : "$Players" } <--- must be "$Related.Players"



 Comments   
Comment by Jeffrey Yemin [ 22/Jan/19 ]

Related to CSHARP-2046

Generated at Wed Feb 07 21:41:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.