command命令语法:
https://docs.mongodb.com/manual/reference/command/find/#dbcmd.find
db.runCommand(
{
find: "restaurants",
filter: { rating: { $gte: 9 }, cuisine: "italian" },
projection: { name: 1, rating: 1, address: 1 },
sort: { name: 1 },
limit: 5
}
)
var bsonDoc = BsonDocument.Parse("{"find":"producer"}");
var cmd = new BsonDocumentCommand<FindCommandResult<Person>>(bsonDoc);
var result = db.RunCommand<FindCommandResult<Person>>(cmd);
[BsonIgnoreExtraElements]
public class FindCommandResult<T>
{
public Double ok { get; set; }
[BsonElement("cursor")]
public ResultCursor<T> cursor { get; set; }
}
[BsonIgnoreExtraElements]
public class ResultCursor<T>
{
public long id { get; set; }
public String ns { get; set; }
[BsonElement("firstBatch")]
public T[] firstBatch { get; set; }
}