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


C# IMongoDatabase.CreateCollectionAsync方法代码示例

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


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

示例1: firstTimeInstallDataBase

		private async void firstTimeInstallDataBase (IMongoDatabase database, string rootPath){
			try {
				if (!CollectionExistsAsync (database, "actors").Result) {
					await database.CreateCollectionAsync ("actors");

					var actors = new ActorRepository();
					foreach (Actor actor in actors.Retrieve(rootPath))
					{
						var collectionActors = database.GetCollection<Actor>("actors");
						await collectionActors.InsertOneAsync(actor);
					}
				}

				if (!CollectionExistsAsync (database, "movies").Result) {
					await database.CreateCollectionAsync ("movies");

					var movies = new MovieRepository();
					foreach (Movie movie in movies.Retrieve(rootPath))
					{
						var collectionActors = database.GetCollection<Movie>("movies");
						await collectionActors.InsertOneAsync(movie);
					}
				}
			}
			catch {
				throw;
			}
		}
开发者ID:RafaelDelboni,项目名称:Angular-WebAPI-MongoDB-TokenAuth,代码行数:28,代码来源:Bootstrapper.cs

示例2: FullTextSearch

        public FullTextSearch(string databaseName = "test", MongoUrl url = null)
        {
            mongoClient = url == null ? new MongoClient() : new MongoClient(url);
            database = mongoClient.GetDatabase(databaseName);

            database.CreateCollectionAsync("Students").Wait();
        }
开发者ID:maximburyak,项目名称:TODA,代码行数:7,代码来源:FullTextSearch.cs

示例3: CreateCollection

        private void CreateCollection(IMongoDatabase db, string collectionName)
        {
            var cob = new CreateCollectionOptions();

            SetCappedCollectionOptions(cob);

            db.CreateCollectionAsync(collectionName, cob).GetAwaiter().GetResult();
        }
开发者ID:seanfitzg,项目名称:log4mongo-net,代码行数:8,代码来源:MongoDBAppender.cs

示例4: CreateCollectionAsync

        private static async Task CreateCollectionAsync(IMongoDatabase mongoDatabase, string collectionName, long? cappedCollectionSize, long? maxNumberOfDocuments)
        {
            var createCollectionOptions = new CreateCollectionOptions()
            {
                Capped = true,
                MaxSize = cappedCollectionSize ?? DefaultCappedCollectionSize,
                MaxDocuments = maxNumberOfDocuments ?? DefaultCappedCollectionMaxDocuments
            };

            await mongoDatabase.CreateCollectionAsync(collectionName ?? CollectionDefaulName, createCollectionOptions);
        }
开发者ID:AzharIqbal84,项目名称:ForwardMongoLogger,代码行数:11,代码来源:MongoDbHelper.cs

示例5: MongoDBClient

 public MongoDBClient(string _collection)
 {
     this.connectionString = "mongodb://groupeNoSql3:[email protected]:55564/stockexchange";
     //mongo ds055564.mongolab.com:55564/stockexchange -u groupeNoSql3 -p groupeNoSql3
     client = new MongoClient(this.connectionString);
     database = client.GetDatabase("stockexchange");
     this.collection = database.GetCollection<BsonDocument>(_collection);
     if (this.collection == null) database.CreateCollectionAsync(_collection);
 }
开发者ID:NicolasGH,项目名称:Projet_final_NoSql,代码行数:9,代码来源:MongoDBClient.cs


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