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


C# IMongoDatabase.GetCollection方法代码示例

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


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

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

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

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

示例4: GetNextHi

        private long GetNextHi(string collectionName, IMongoDatabase database)
        {
            while (true)
            {
                try
                {
                    var update = new Expando();
                    update["$inc"] = new { ServerHi = 1 };

                    var hiLoKey = database.GetCollection<NormHiLoKey>().FindAndModify(new { _id = collectionName }, update);
                    if (hiLoKey == null)
                    {
                        database.GetCollection<NormHiLoKey>().Insert(new NormHiLoKey { CollectionName = collectionName, ServerHi = 2 });
                        return 1;
                    }

                    var newHi = hiLoKey.ServerHi;
                    return newHi;
                }
                catch (MongoException ex)
                {
                    if (!ex.Message.Contains("duplicate key"))
                        throw;
                }
            }
        }
开发者ID:gaoninggn,项目名称:NoRM,代码行数:26,代码来源:HiLoIdGenerator.cs

示例5: AgentController

        public AgentController()
        {
            mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString);

            KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements");
            usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users");
            requirementsCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Requirements");
        }
开发者ID:thEpisode,项目名称:Sistema-de-gestion-de-requerimientos-konrad-lorenz,代码行数:8,代码来源:AgentController.cs

示例6: MongoModelRepository

 public MongoModelRepository(IMongoDatabase database)
 {
     _composedModelsCollection = database.GetCollection<ComposedModel>("ComposedModel");
     _setDataCollection = database.GetCollection<SetData>("SetData");
     _parameterDataCollection = database.GetCollection<ParameterDataStorageModel>("ParameterData");
     _parameterDataItemCollection = database.GetCollection<ParameterDataItemStorageModel>("ParameterDataItem");
     _scenariosCollection = database.GetCollection<Scenario>("Scenario");
 }
开发者ID:teledu,项目名称:MoManI,代码行数:8,代码来源:MongoModelRepository.cs

示例7: DealsDb

 public DealsDb(string databaseName)
 {
     var cli = new MongoClient("mongodb://localhost:27017");
     db = cli.GetDatabase(databaseName);
     dealCollection = db.GetCollection<Deal>(DealsCollectionName);
     userCollection = db.GetCollection<User>(UserCollectionName);
     ratingCollection = db.GetCollection<Rating>(RatingCollectionName);
     LoggedInUsers = new Dictionary<Guid, User>();
 }
开发者ID:libjared,项目名称:shoppingdeals,代码行数:9,代码来源:DealsDb.cs

示例8: MongoService

        // useful resources:
        // http://mongodb.github.io/mongo-csharp-driver/2.0/getting_started/quick_tour/
        // http://dotnetcodr.com/data-storage/


        /// <summary>
        /// Default constructor for the repository
        /// </summary>
        public MongoService()
        {
            string connection = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString;
            client = new MongoClient(connection);
            database = client.GetDatabase("CMEdata");
            inputdata = database.GetCollection<InputData>("inputdata");
            datesets = database.GetCollection<DateSet>("datesets");
            tests = database.GetCollection<Test>("tests");
        }
开发者ID:martin-chambers,项目名称:GetCMEWebAPI,代码行数:17,代码来源:MongoService.cs

示例9: HomeController

        public HomeController()
        {
            mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString);

            KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements");
            usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users");
            requirementsCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Requirements");
                        
            //https://www.mongodb.com/blog/post/introducing-20-net-driver?jmp=docs&_ga=1.196294954.721581952.1441258055
        }
开发者ID:thEpisode,项目名称:Sistema-de-gestion-de-requerimientos-konrad-lorenz,代码行数:10,代码来源:HomeController.cs

示例10: MongoDbRepository

        public MongoDbRepository(IOptions<AppSettings> appSettings)
        {
            _client = new MongoClient(appSettings.Value.MongoDbConnectionString);
            _database = _client.GetDatabase(appSettings.Value.MongoDbName);

            _tweetCollection = _database.GetCollection<Tweet>("tweets");
            _userFollowsCollection = _database.GetCollection<UserFollows>("user_follows");
            _userLikesCollection = _database.GetCollection<UserLikes>("user_likes");
            _conversationCollection = _database.GetCollection<Conversation>("conversations");
            _userNotificationCollection = _database.GetCollection<UserNotifications>("user_notifications");
        }
开发者ID:kristersz,项目名称:Tweetus,代码行数:11,代码来源:MongoDbRepository.cs

示例11: ImportNewUsersStep

        public ImportNewUsersStep(string database, string repository, string month)
        {
            _repository = repository;

            _month = month;

            var client = new MongoClient("mongodb://app-svr.cloudapp.net:27017/" + database);

            _database = client.GetDatabase(database);

            _userCollection = _database.GetCollection<BsonDocument>("users");

            _threadCollection = _database.GetCollection<BsonDocument>(_repository + "_" + _month + "_" + "threads");
        }
开发者ID:Myfreedom614,项目名称:toolkit,代码行数:14,代码来源:ImportNewUsersStep.cs

示例12: UpdateMonthlyAskerTagsToAskerActivityStep

        public UpdateMonthlyAskerTagsToAskerActivityStep(string database, string repository, string month)
        {
            _repository = repository;

            _month = month;

            var client = new MongoClient("mongodb://app-svr.cloudapp.net:27017/" + database);

            _database = client.GetDatabase(database);

            _askerTagCollection = _database.GetCollection<BsonDocument>(_repository + "_user_tags");

            _askerActivityCollection = _database.GetCollection<BsonDocument>(_repository + "_asker_activities");
        }
开发者ID:Myfreedom614,项目名称:toolkit,代码行数:14,代码来源:UpdateMonthlyAskerTagsToAskerActivityStep.cs

示例13: ImportNewUsersStep

        public ImportNewUsersStep(string repository, string month, EasyAnalysis.Framework.ConnectionStringProviders.IConnectionStringProvider mongoDBDataProvider)
        {
            _repository = repository;

            _month = month;
            
            var client = new MongoClient(mongoDBDataProvider.GetConnectionString(repository));

            _database = client.GetDatabase(repository);

            _userCollection = _database.GetCollection<BsonDocument>("users");

            _threadCollection = _database.GetCollection<BsonDocument>(_month + "_" + "threads");
        }
开发者ID:dream-365,项目名称:toolkit,代码行数:14,代码来源:ImportNewUsersStep.cs

示例14: GetAllTraders

        public ICollection<Trader> GetAllTraders(IMongoDatabase database)
        {
            var collection = database.GetCollection<Trader>(TradersCollectionName);
            var rest = collection.Find(t => true).ToListAsync().Result;

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

示例15: Querying

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

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


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