morning, I'm trying to add a dynamic array of booleans as a single
object so that I can use multikey approach to index (http://
www.mongodb.org/display/DOCS/Using+Multikeys+to+Simulate+a+Large+Number+of+Indexes)
I can't figure out the proper way to do this with the c# driver, my
object arrays end up looking like this:
attribs : [
... { \"Value\": false },
... { \"Value\" : true },
... { \"Value\" : false },
... { \"Value\" : true } ]
... };
but should look like this
attribs : [
... { HasPool : false },
... { HasGarage : true },
... { HasBasement : false },
... { IsHOA : true } ]
... };
code I'm using below, trying to approaches..
BsonDocument newDoc = new BsonDocument();
var boolAttribs = new BsonDocument();
var bsonArray = new BsonArray();
boolProps.ForEach(delegate(System.Reflection.PropertyInfo p)
{
boolAttribs.Add(new BsonElement(p.Name,
true));
bsonArray.Add(new BsonElement(p.Name,
true).ToBsonDocument());
});
newDoc.Add(MapToMongoFieldName("BooleanAttributes"), boolAttribs);
newDoc.Add(MapToMongoFieldName("BooleanAttributes2"), bsonArray);