mongodb-csharp CRUD Operations in MongoDB C# Insert a Document


Example

var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("test");
var collection = database.GetCollection < Interactions > ("Interactions");

var newItem = new Interactions{
    SiteName = "Example",
    Pages = new List < Pages > {
        new Pages {
            Url =  @ "http://stackoverflow.com/documentation/mongodb-csharp",
            VisitPageIndex = 4
        },
        new Pages {
            Url =  @ "https://github.com/",
            VisitPageIndex = 2
        },
    }
};
collection.InsertOne(newItem);