[英]how to convert a bsondocument into a strongly typed object without bson deserializer in monogodb using C#
I'm trying to fetch class object('let it be myObj') with built in find'<'myObj'>'(Filter) function in C# But it returns only bsonDocument我正在尝试使用 C# 中的内置find'<'myObj'>'(Filter)函数获取类对象('让它成为 myObj')但它只返回 bsonDocument
Note: my key and value pair will be dynamic for the filter注意:我的键值对对于过滤器来说是动态的
my Code: List'<'myObj'>' obj = collection.Find(BuilderFilter.Eq("key", "value")).Skip(skipValue).Limit(limitValue).ToList();我的代码: List'<'myObj'>' obj = collection.Find(BuilderFilter.Eq("key", "value")).Skip(skipValue).Limit(limitValue).ToList();
doc reference for the find function: https://api.mongodb.com/csharp/2.0/html/M_MongoDB_Driver_IMongoCollectionExtensions_Find__1.htm find 函数的文档参考: https : //api.mongodb.com/csharp/2.0/html/M_MongoDB_Driver_IMongoCollectionExtensions_Find__1.htm
For finding a document based on a query from MongoDB with C# driver,为了使用 C# 驱动程序根据来自 MongoDB 的查询查找文档,
myObj record = collection.Find(Builders<myObj>.Filter.Eq(x => x.property, valueToLookup)).FirstOrDefault();
where collection is of type IMongoCollection
.其中 collection 的类型为
IMongoCollection
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.