Below is the sample Bson document which is unstructured. As I am new to MongoDB try to learn building queries.
{
"_id":ObjectId("562e7c594c12942f08fe4192"),
"shapes":[
{
"shape":"square",
"color":"blue"
},
{
"shape":"circle",
"color":"red"
}
]
},
{
"_id":ObjectId("562e7c594c12942f08fe4193"),
"shapes":[
{
"shape":"square",
"color":"black"
},
{
"shape":
{
"shape_s_time":""2020-06-29T12:00:14.3716902Z"
"shape__time":""2020-06-29T12:00:16.3716902Z"
},
"color":"green"
}
]
}
I have tried this code
var collection= db.GetCollection<BsonDocument>("Test");
var result = collection.Find(new BsonDocument()).Project(Builders<BsonDocument>.Projection.Include("shapes.shape.shape_s_time")).ToList();
Could someone tell how to get values?
you have problems with data. The two above document examples works without any issues. It looks like some of your documents here shapes.shape.shape_s_time
have different format
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.