本文整理汇总了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);
}
}
示例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 },
});
}
示例3: InitializeCollection
private void InitializeCollection(IMongoCollection<BsonDocument> collection, List<BsonDocument> documents)
{
collection.DeleteMany(new BsonDocument());
if (documents.Count > 0)
{
collection.InsertMany(documents);
}
}
示例4: PersistEvents
private static void PersistEvents(IMongoCollection<ReiEventBase> coll, ReportingEntityInstance instance)
{
var validations = instance.GetUncommittedChanges();
coll.InsertMany(validations.OfType<ReiEventBase>());
instance.MarkChangesAsCommitted();
}