我想使用New_amt
从以下文档中检索C#
字段:
> db.Customer.find().pretty()
{
"_id" : ObjectId("5c6daad5fc5bef1b941bec3c"),
"Customer_Id" : "1",
"Name" : "aaaaa",
"Address" : "lalalal",
"PhoneNo" : "7878787",
"OptionalNo" : "7878787",
"Date" : ISODate("2019-02-20T19:30:29.095Z"),
"Installment" : [
{
"id" : ObjectId("5c6dab0bfc5bef1b941bec3f"),
"New_amt" : "0",
"Net_amt" : "6000",
"Paid" : "200",
"Remains" : "5800",
"Date" : ISODate("2019-02-20T19:31:23.772Z")
}
]
}
答案 0 :(得分:0)
您一次需要MongoDriver来c#
实例
var _client = new MongoClient("mongodb://localhost:27017");
var _database = _client.GetDatabase("YOUR DATABASE");
var _bitCollection = _database.GetCollection<MODEL>("YOUR COLLECTION");
一次可以过滤
var filter = Builders<MODEL>.Filter.Eq(fieldName, fieldValue);
var result = await _bitCollection.Find(filter).ToListAsync();
,结果返回一个列表,如果没有模型,则可以使用 动态作为模型,但有时会遇到很多问题