本文整理汇总了C#中IMongoCollection.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# IMongoCollection.Delete方法的具体用法?C# IMongoCollection.Delete怎么用?C# IMongoCollection.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMongoCollection
的用法示例。
在下文中一共展示了IMongoCollection.Delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteAllDocumentsFromCollection
/// <summary>
/// Demo deleting documents from collection.
/// </summary>
/// <param name="orders">The orders.</param>
private static void DeleteAllDocumentsFromCollection(IMongoCollection orders)
{
Console.WriteLine("\n\n======= Delete Test =======");
Console.WriteLine(string.Format("Document Count Before Delete: [ {0} ]", orders.Count()));
// Delete documents matching a criteria.
orders.Delete(new Document { { "customerName", "Elmer Fudd" } });
Console.WriteLine(string.Format("Document Count After Deleting Elmer Fudd: [ {0} ]", orders.Count()));
// Delete all docs.
orders.Delete(new Document());
Console.WriteLine("Deleted all docs");
Console.WriteLine(string.Format("Document Count After Deleting All Docs: [ {0} ]\n", orders.Count()));
}
示例2: QueryTests
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 { });
}
示例3: TestSetup
public void TestSetup()
{
personCollection = this.DB.GetCollection<Person>("people");
personCollection.Delete(new { }, true);
personCollection.Insert(new Person { FirstName = "Bob", LastName = "McBob", Age = 42, Address = new Address { City = "London" }, Aliases = new[]{"Blub"} }, true);
personCollection.Insert(new Person { FirstName = "Jane", LastName = "McJane", Age = 35, Address = new Address { City = "Paris" } }, true);
personCollection.Insert(new Person { FirstName = "Joe", LastName = "McJoe", Age = 21, Address = new Address { City = "Chicago" } }, true);
orgCollection = this.DB.GetCollection<Organization>("orgs");
orgCollection.Delete(new { }, true);
orgCollection.Insert(new Organization { Name = "The Muffler Shanty", Address = new Address { City = "London" } }, true);
}