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


C# IMongoDatabase.ListCollections方法代码示例

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

示例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);
                }
            }
        }
开发者ID:GeneralXception,项目名称:serilog-sinks-mongodb,代码行数:32,代码来源:MongoDBSink.cs


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