本文整理汇总了C#中IMongoDatabase.ListCollections方法的典型用法代码示例。如果您正苦于以下问题:C# IMongoDatabase.ListCollections方法的具体用法?C# IMongoDatabase.ListCollections怎么用?C# IMongoDatabase.ListCollections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMongoDatabase
的用法示例。
在下文中一共展示了IMongoDatabase.ListCollections方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstantiateMongoCollections
internal override void InstantiateMongoCollections(IMongoDatabase database)
{
var collections = database.ListCollections().ToList();
}
示例2: MongoDBSink
/// <summary>
/// Construct a sink posting to a specified database.
/// </summary>
/// <param name="database">The MongoDB database.</param>
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
/// <param name="period">The time to wait between checking for event batches.</param>
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
/// <param name="collectionName">Name of the MongoDb collection to use for the log. Default is "log".</param>
/// <param name="collectionCreationOptions">Collection Creation Options for the log collection creation.</param>
public MongoDBSink(IMongoDatabase database, int batchPostingLimit, TimeSpan period, IFormatProvider formatProvider, string collectionName, CreateCollectionOptions collectionCreationOptions)
: base(batchPostingLimit, period)
{
if (database == null) throw new ArgumentNullException("database");
_mongoDatabase = database;
_collectionName = collectionName;
_collectionCreationOptions = collectionCreationOptions;
_formatProvider = formatProvider;
// capped collections have to be created because GetCollection doesn't offer the option to create one implicitly
// only create one if it doesn't already exist
if (_collectionCreationOptions.Capped.GetValueOrDefault(false))
{
if (_mongoDatabase.ListCollections(new ListCollectionsOptions
{
Filter = new BsonDocument {{"name", _collectionName}}
}).ToList().Count == 0)
{
_mongoDatabase.CreateCollection(_collectionName, _collectionCreationOptions);
}
}
}