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


C# IMongoCollection.InsertMany方法代码示例

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


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

示例1: Execute

 protected override void Execute(IMongoCollection<BsonDocument> collection, BsonDocument outcome, bool async)
 {
     if (async)
     {
         collection.InsertManyAsync(_documents).GetAwaiter().GetResult();
     }
     else
     {
         collection.InsertMany(_documents);
     }
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:11,代码来源:InsertManyTest.cs

示例2: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            var client = DriverTestConfiguration.Client;
            var db = client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName);
            db.DropCollection(DriverTestConfiguration.CollectionNamespace.CollectionName);
            _collection = db.GetCollection<ZipEntry>(DriverTestConfiguration.CollectionNamespace.CollectionName);

            // This is a subset of the data from the mongodb docs zip code aggregation examples
            _collection.InsertMany(new[]
            {
                new ZipEntry { Zip = "01053", City = "LEEDS", State = "MA", Population = 1350 },
                new ZipEntry { Zip = "01054", City = "LEVERETT", State = "MA", Population = 1748 },
                new ZipEntry { Zip = "01056", City = "LUDLOW", State = "MA", Population = 18820 },
                new ZipEntry { Zip = "01057", City = "MONSON", State = "MA", Population = 8194 },
                new ZipEntry { Zip = "36779", City = "SPROTT", State = "AL", Population = 1191 },
                new ZipEntry { Zip = "36782", City = "SWEET WATER", State = "AL", Population = 2444 },
                new ZipEntry { Zip = "36783", City = "THOMASTON", State = "AL", Population = 1527 },
                new ZipEntry { Zip = "36784", City = "THOMASVILLE", State = "AL", Population = 6229 },
            });
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:20,代码来源:AggregationSample.cs

示例3: InitializeCollection

 private void InitializeCollection(IMongoCollection<BsonDocument> collection, List<BsonDocument> documents)
 {
     collection.DeleteMany(new BsonDocument());
     if (documents.Count > 0)
     {
         collection.InsertMany(documents);
     }
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:8,代码来源:GridFSTestBase.cs

示例4: PersistEvents

 private static void PersistEvents(IMongoCollection<ReiEventBase> coll, ReportingEntityInstance instance)
 {
     var validations = instance.GetUncommittedChanges();
     coll.InsertMany(validations.OfType<ReiEventBase>());
     instance.MarkChangesAsCommitted();
 }
开发者ID:DavidHoerster,项目名称:EventTest,代码行数:6,代码来源:Program.cs


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