/// <summary> /// 若设置过MongoServerAddress 、MongReplicaSetName则已cluster优先 /// 否则默认为最后一个ConnectionString设置 /// </summary> /// <param name="inputStr"></param> public MongoRepository(string inputStr) { if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["MongReplicaSetName"]) && !string.IsNullOrEmpty(ConfigurationManager.AppSettings["MongoServerAddress"])) { this.collection = Extentions <TKey> .GetCollectionFromCluster <T>(inputStr); } else { this.collection = Extentions <TKey> .GetCollectionFromConnectionString <T>(inputStr); } }
/// <summary> /// 若设置过MongoServerAddress 、MongReplicaSetName则已cluster优先 /// 否则默认为最后一个ConnectionString设置 /// </summary> /// <param name="connectionString"></param> public MongoDBOperatorBase(string connectionString) { _connStr = connectionString; if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["MongReplicaSetName"]) && !string.IsNullOrEmpty(ConfigurationManager.AppSettings["MongoServerAddress"])) { this.collection = Extentions <TKey> .GetCollectionFromCluster <T>(connectionString); } else { this.collection = Extentions <TKey> .GetCollectionFromConnectionString <T>(connectionString); } }