当前位置: 首页>>代码示例>>C#>>正文


C# IMongoCollection.Delete方法代码示例

本文整理汇总了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()));
        }
开发者ID:ChrisEdwards,项目名称:IntroducingMongoDB,代码行数:19,代码来源:Program.cs

示例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 { });
 }
开发者ID:gaoninggn,项目名称:NoRM,代码行数:10,代码来源:QueryTests.cs

示例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);
        }
开发者ID:jango2015,项目名称:MongoDB_Client_.Net,代码行数:12,代码来源:LinqExtensionsTests.cs


注:本文中的IMongoCollection.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。