projection wont work in mongodb c# driver -
i have class executes mongo queries works when send projection in query, projection won't work , mongo return hole document
whats matter?
query = new querydocument( bsonserializer.deserialize<bsondocument>(querystr));
querystr="{family:'james'},{}" =>
ok
querystr="{},{family:0}" =>
not ok. return columns, don't want family column
remember: want method. not methods. because want send query mongo. i've read mapped mongo objects orms.
just want method. thanks
did new c# 2.0 driver documentation? looks projection part of options argument can give findasync
private static void find(imongocollection<person> mongocollection) { var query = builders<person>.filter.eq(p => p.name, "bob"); var options = new findoptions<person>() { projection = builders<person>.projection .include(p => p.name) .exclude(p => p.id) }; var result = await mongocollection.findasync(query, options);
...
the bsondocument object created json {.a.}{.b.} in question has 2 braces-pairs, , first 1 matter (a). ok, since projection , query 2 separate items. personally
Comments
Post a Comment