Ejemplo n.º 1
0
        public static DBMongoKit GetMongoDBInstance(DBMongoConfig config)
        {
            if (mongoKit == null)
            {
                lock (nameof(DBMongoKit))// lockobject)
                {
                    if (mongoKit == null)
                    {
                        mongoKit = new DBMongoKit(config, null);
                    }
                }
            }

            return(mongoKit);
        }
Ejemplo n.º 2
0
        private DBMongoKit(DBMongoConfig config, string tableName)
        {
            if (config == null)
            {
                //mongodb://Jianny:a123456@localhost/CommonSchemeCoreLog
                config = new DBMongoConfig()
                {
                    Host = "10.10.111.28:27017", UserName = "******", Password = "******", DBName = "CommonSchemeCoreLog"
                };
            }
            string connStr = string.Format("mongodb://{0}:{1}@{2}/{3}", config.UserName, config.Password, config.Host, config.DBName);

            mongoClient = new MongoClient(connStr);
            db          = mongoClient.GetDatabase(config.DBName);
            collections = new Dictionary <string, IMongoCollection <BsonDocument> >();
            //collection = db.GetCollection<BsonDocument>(tableName);
        }