public QueryTests() { _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false"); _collection = _server.GetCollection<Person>("People"); //cause the collection to exist on the server by inserting, then deleting some things. _collection.Insert(new Person()); _collection.Delete(new { }); }
public QueryTests() { var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true"); _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false"); _collection = _server.GetCollection<Person>("People"); _buildInfo = admin.BuildInfo(); //cause the collection to exist on the server by inserting, then deleting some things. _collection.Insert(new Person()); _collection.Delete(new { }); }
/// <summary> /// Demo deleting documents from collection. /// </summary> /// <param name="orders">The orders.</param> private static void DeleteAllDocumentsFromCollection(MongoCollection<Order> collection) { Console.WriteLine("\n\n======= Delete Documents ======="); Console.WriteLine(string.Format("Document Count Before Delete: [ {0} ]", collection.Count())); // Delete documents matching a criteria. collection.Delete( new {CustomerName = "Elmer Fudd"} ); Console.WriteLine(string.Format("Document Count After Deleting Elmer Fudd: [ {0} ]", collection.Count())); // Delete all docs. collection.Delete( new {} ); Console.WriteLine("Deleted all docs"); Console.WriteLine(string.Format("Document Count After Deleting All Docs: [ {0} ]", collection.Count())); }