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


C# MongoCollection.RemoveAll方法代码示例

本文整理汇总了C#中MongoCollection.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.RemoveAll方法的具体用法?C# MongoCollection.RemoveAll怎么用?C# MongoCollection.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCollection的用法示例。


在下文中一共展示了MongoCollection.RemoveAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MOngoTests

 public MOngoTests()
 {
     server = MongoServer.Create();
     database = server.GetDatabase("Diplome");
     collection = database.GetCollection<Test>("companies");
        collection.RemoveAll();
 }
开发者ID:3guboff,项目名称:Diplome,代码行数:7,代码来源:MOngoTests.cs

示例2: ContactRepository

        public ContactRepository(string connection)
        {
            if (string.IsNullOrWhiteSpace(connection))
            {
                connection = "mongodb://localhost:27017";
            }

            _client = new MongoClient(connection);
            _server = _client.GetServer();
            _database = _server.GetDatabase("Contacts", WriteConcern.Unacknowledged);
            _contacts = _database.GetCollection<Contact>("contacts");

            // Reset database and add some default entries
            _contacts.RemoveAll();
            for (int index = 1; index < 5; index++)
            {
                Contact contact1 = new Contact
                {
                    Email = string.Format("test{0}@example.com", index),
                    Name = string.Format("test{0}", index),
                    Phone = string.Format("{0}{0}{0} {0}{0}{0} {0}{0}{0}{0}", index)
                };
                AddContact(contact1);
            }
        }
开发者ID:wk-j,项目名称:asp-samples,代码行数:25,代码来源:ContactRepository.cs

示例3: TodoRepository

        public TodoRepository(string connection)
        {
            if (string.IsNullOrWhiteSpace(connection))
            {
                connection = ConfigurationManager.AppSettings["TodoConnectionString"];
            }

            _server = MongoServer.Create(connection);
            _database = _server.GetDatabase(ConfigurationManager.AppSettings["TodoDatabaseName"], SafeMode.True);
            _todos = _database.GetCollection<Todo>(ConfigurationManager.AppSettings["TodoTableName"]);

            bool resetData = true;
            bool.TryParse(ConfigurationManager.AppSettings["ResetData"], out resetData);

            if (resetData)
            {
                _todos.RemoveAll();
                for (int i = 0; i < 5; i++)
                {
                    Todo todo = new Todo
                    {
                        Description = string.Format("Todo {0}", i + 1),
                        Done = (i % 3 == 0 ? true : false),
                        CreationDatetime = DateTime.Now,
                        DoneDatetime = null
                    };

                    if (todo.Done)
                        todo.DoneDatetime = DateTime.Now;

                    AddTodo(todo);
                }
            }
        }
开发者ID:brucculeri-elipse,项目名称:testwebapi,代码行数:34,代码来源:TodoRepository.cs

示例4: ResetDb

 public void ResetDb()
 {
     var cli = new MongoClient(CONNECTIONSTRING);
     var ser = cli.GetServer();
     var db = ser.GetDatabase("Instavote");
     _col = db.GetCollection("Trainings");
     _col.RemoveAll();
 }
开发者ID:ralfw,项目名称:instavote.open,代码行数:8,代码来源:test_MongoDbRepository.cs

示例5: SetUp

        public void SetUp()
        {
            GlobalContext.Properties.Clear();
            ThreadContext.Properties.Clear();

            MongoServer conn = MongoServer.Create("mongodb://localhost");
            MongoDatabase db = conn.GetDatabase("log4net");
            _collection = db.GetCollection("logs");
            _collection.RemoveAll();
        }
开发者ID:ryanande,项目名称:log4mongo-net,代码行数:10,代码来源:MongoDBAppenderTest.cs

示例6: ClearRecords

 private static void ClearRecords(MongoCollection<BsonDocument> collection)
 {
     collection.RemoveAll();
 }
开发者ID:archangelmichael,项目名称:DB-TeamWork-TeamBlackDragon,代码行数:4,代码来源:MongoDBImport.cs

示例7: SetUp

 public void SetUp()
 {
     topicsCollection =  mongoDb.GetCollection(MongoDbConstants.Collections.Topics);
     topicsCollection.RemoveAll();
 }
开发者ID:jasondentler,项目名称:Hermes,代码行数:5,代码来源:ExistTopicByNameTests.cs


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