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


C# IMongoDatabase类代码示例

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


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

示例1: CollectionExpression

 public CollectionExpression(Alias alias, IMongoDatabase database, string collectionName, Type documentType)
     : base(MongoExpressionType.Collection, typeof(void), alias)
 {
     CollectionName = collectionName;
     Database = database;
     DocumentType = documentType;
 }
开发者ID:jango2015,项目名称:MongoDB_Client_.Net,代码行数:7,代码来源:CollectionExpression.cs

示例2: GetAllProducts

        public ICollection<Product> GetAllProducts(IMongoDatabase database, string collectionName)
        {
            var collection = database.GetCollection<Product>(collectionName);
            var rest = collection.Find(_ => true).ToListAsync().Result;

            return rest;
        }
开发者ID:ni4ka7a,项目名称:Molybdenum-Team,代码行数:7,代码来源:MongoImporter.cs

示例3: 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

示例4: MongoDBStorage

		public MongoDBStorage(IMongoDatabase database)
		{
			Revisions = database.GetCollection<RevisionModel>("revisions");
			Users = database.GetCollection<UserModel>("users");

			Task.Run(() => SetUp()).Wait();
		}
开发者ID:avgoncharov,项目名称:BuildRevisionCounter,代码行数:7,代码来源:MongoDBStorage.cs

示例5: GetCollection

        public IMongoCollection<BsonDocument> GetCollection(IMongoDatabase mongoDatabase, bool? cappedCollection,
            string collectionName, long? cappedCollectionSize, long? maxNumberOfDocuments)
        {
            IMongoCollection<BsonDocument> retVal = null;

            if (cappedCollection == null || !cappedCollection.Value)
            {
                retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
                return retVal;
            }
            
            if (!IsCollectionExistsAsync(mongoDatabase, collectionName).Result)
            {
                CreateCollectionAsync(mongoDatabase, collectionName, cappedCollectionSize, maxNumberOfDocuments).Wait();
                retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
                return retVal;
            }

            if (IsCappedCollection(collectionName, mongoDatabase).Result)
            {
                retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
                return retVal;
            }


            if (ConvertCollectionToCapped(collectionName, mongoDatabase, cappedCollectionSize, maxNumberOfDocuments).Result)
            {
                retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
            }
            
            return retVal;
        }
开发者ID:AzharIqbal84,项目名称:ForwardMongoLogger,代码行数:32,代码来源:MongoDbHelper.cs

示例6: TokenHandleStore

 public TokenHandleStore(IMongoDatabase db, 
     StoreSettings settings, 
     IClientStore clientStore) 
     : base(db, settings.TokenHandleCollection)
 {
     _serializer = new TokenSerializer(clientStore);
 }
开发者ID:nielsmeijssen,项目名称:IdentityServer.v3.MongoDb,代码行数:7,代码来源:TokenHandleStore.cs

示例7: AdminService

 public AdminService(IMongoClient client, IMongoDatabase db, StoreSettings settings)
 {
     _client = client;
     _db = db;
     _settings = settings;
     _clientSerializer = new ClientSerializer();
 }
开发者ID:FeodorFitsner,项目名称:IdentityServer.v3.Admin.MongoDb,代码行数:7,代码来源:AdminService.cs

示例8: MongoConfigurationRepository

        public MongoConfigurationRepository(string connection, string databaseName)
        {
            var mongoClient = new MongoClient(MongoClientSettings.FromUrl(new MongoUrl(connection ?? Connection)));
            database = mongoClient.GetDatabase(databaseName ?? DatabaseName);

            InitCollection();
        }
开发者ID:cimdalli,项目名称:DynamicConfigurator,代码行数:7,代码来源:MongoConfigurationRepository.cs

示例9: Init

 public void Init()
 {
     Client = new MongoClient(ConnString);
     DataBase = Client.GetDatabase("mongoLog");
     Users = DataBase.GetCollection<User>("Users");
     Datas = DataBase.GetCollection<Data>("Datas");
 }
开发者ID:ozt88,项目名称:MongoLog,代码行数:7,代码来源:DBHelper.cs

示例10: MProjects

        static MProjects()
        {
            var connectionString = Settings.Default.MongoConnectionString;
            var mongoClient = new MongoClient(connectionString);

            Database = mongoClient.GetDatabase(Settings.Default.MongoDBName);
        }
开发者ID:DenysGranevych,项目名称:Denys-library,代码行数:7,代码来源:MProjects.cs

示例11: Querying

        public Querying()
        {
            client = new MongoClient(); ;
            database = client.GetDatabase("test");

            collection = database.GetCollection<Student>("Users");
        }
开发者ID:maximburyak,项目名称:TODA,代码行数:7,代码来源:Querying.cs

示例12: Logger

 public Logger(string logger)
 {
     var client = new MongoClient(Properties.Settings.Default.Mongo_log);
     _db = client.GetDatabase("patientcarelog");
     _logCollection = _db.GetCollection<BsonDocument>("Logs");
     _logger = logger;
 }
开发者ID:dsb92,项目名称:patientcare,代码行数:7,代码来源:Logger.cs

示例13: DetailController

 /// <summary>
 /// Details controller constructor
 /// </summary>
 public DetailController()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString);
     _log = new Logger("WebAPI:DetailController");
     _db = client.GetDatabase("patientcaredb");
     _details = _db.GetCollection<BsonDocument>("Detail");
 }
开发者ID:dsb92,项目名称:patientcare,代码行数:10,代码来源:DetailController.cs

示例14: InitiateDatabase

 private void InitiateDatabase()
 {
     var connectionString = ConfigurationManager.ConnectionStrings["Mongo.ConnectionString"].ConnectionString;
     var mongoUrlBuilder = new MongoUrlBuilder(connectionString);
     mongoClient = new MongoClient(mongoUrlBuilder.ToMongoUrl());
     Database = mongoClient.GetDatabase(mongoUrlBuilder.DatabaseName);
 }
开发者ID:tareq89,项目名称:TaskCat,代码行数:7,代码来源:DbContext.cs

示例15: PatientRepository

 /// <summary />
 public PatientRepository()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare_datamock"].ConnectionString);
     _log = new Logger("WebAPI : PatientRepository");
     _db = client.GetDatabase("patientcare_datamock");
     _patients = _db.GetCollection<BsonDocument>("Patients");
 }
开发者ID:dsb92,项目名称:patientcare,代码行数:8,代码来源:PatientRepository.cs


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