[CSHARP-1218] Null Reference Exception using Unwind with a Projection Created: 22/Mar/15  Updated: 02/Apr/15  Resolved: 24/Mar/15

Status: Closed
Project: C# Driver
Component/s: API
Affects Version/s: 2.0
Fix Version/s: 2.0

Type: Bug Priority: Minor - P4
Reporter: Craig Wilson Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Given this schema:

> db.foo.find().pretty()
{
        "_id" : 1,
        "bars" : [
                {
                        "x" : 1,
                        "y" : 2
                },
                {
                        "x" : 2,
                        "y" : 3
                },
                {
                        "x" : 1,
                        "y" : 4
                }
        ]
}

and these classes:

        private class Foo
        {
            public int Id;
 
            public List<Bars> Bars;
        }
 
        private class UnwoundFoo
        {
            public int Id;
            [BsonElement("Bars")]
            public Bar Bar;
        }
 
        private class Bar
        {
            [BsonElement("x")]
            public int X;
            [BsonElement("y")]
            public int Y;
        }

The following aggregation query results in a NRE:

    var list = await col.Aggregate()
                .Unwind<Foo, UnwoundFoo>(x => x.Bars)
                .Match(x => x.Bar.X == 1)
                .Project(x => new { X = x.Bar.X, Y = x.Bar.Y })
                .ToListAsync();



 Comments   
Comment by Craig Wilson [ 24/Mar/15 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1221: Removed unnecessary argument null check.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/d1bad7391198cbea3e21941f125f5df024c9bd01

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