static void DeleteCollection() { dynamic storage = new DynStorage("mongodb://localhost/ConsoleExample"); // Delete EmployeesColl collection if it exists to make sure we start with fresh data storage.Delete("EmployeesColl"); }
static void CreateDocument() { // Create a MongoDB document. dynamic storage = new DynStorage("mongodb://localhost/ConsoleExample"); // Get reference to the Employees document collection - it's created if it doesn't already exist dynamic employeesCollection = storage.EmployeesColl; // Create a document in the Employees collection for John with his email as the document id - the document is created if it doesn't already exist var employee = employeesCollection.Document("*****@*****.**"); employee.Name = "John Doe"; employee.Salary = 50000; // John earns $50k/year employee.Birthdate = new DateTime(1995, 8, 18); // John was born 08/18/1995 // Save the document to the MongoDB database employee.Save(); }