-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.2.3
-
Component/s: BSON, Feature Request, Serialization
-
Environment:Not environment specific
As per question on SO: http://stackoverflow.com/questions/35362675/mongodb-map-class-from-nested-elements-in-c-sharp
When creating a class map in the BsonClassMap class, I would like to be able to reference nested elements.
e.g.
BsonClassMap.RegisterClassMap<RestaurantAddress>(map => { map.MapMember(c => c.Id).SetElementName(("_id")); map.MapMember(c => c.Building).SetElementName("address.building"); map.MapMember(c => c.Street).SetElementName("address.street"); map.MapMember(c => c.ZipCode).SetElementName("address.zipcode"); });
For a document like:
{ "_id" : ObjectId("56bb82621ff72e0d9ba267cb"), "address" : { "building" : "6409", "coord" : [ -74.005289, 40.628886 ], "street" : "11 Avenue", "zipcode" : "11219" }, "borough" : "Brooklyn", "cuisine" : "American ", "grades" : [ { "date" : ISODate("2014-07-18T00:00:00.000Z"), "grade" : "A", "score" : 12 }, { "date" : ISODate("2013-07-30T00:00:00.000Z"), "grade" : "A", "score" : 12 } ], "name" : "Regina Caterers", "restaurant_id" : "40356649" }