I want to create db stucture (inserting data) via C# with subdocuments. Something similar to picture attached below
Robmongo
I'm using this way to add "normal" kind of db
var task = collection.InsertOneAsync(new person
{
Id = setid,
FirstName = name,
LastName= lastname,
Email = email,
});
But I have no clue how to add subdocs to it.
Try something as below:-
var task = collection.InsertOneAsync(new person
{
Id = setid,
FirstName = name,
LastName= lastname,
Email = email,
playlists = [ //Array of objects
{videos:[ //Array of objects
{
title:"1", description:""
},
{
title:"2", description:""
}
]}
]
});
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.