/// <summary> /// 获取MongoDB的集合对象 /// </summary> /// <typeparam name="DbModel">关联的实体对象信息</typeparam> /// <param name="tableName">表名称</param> /// <returns>存在返回集合对象;否则返回null</returns> public static IMongoCollection <DbModel> GetMongoCollection <DbModel>(String tableName) where DbModel : NoSqlBaseModel { INoSqlProvider provider = NoSqlManager.Create(Common.Utils.Const.AppCode); IMongoCollection <DbModel> collection = provider.GetCollection <DbModel, IMongoCollection <DbModel> >(tableName); if (collection == null) { throw new SystemException(String.Format("获取信息登记模型MongoDB集合失败。CollectionName:{0}", tableName)); } return(collection); }
/// <summary> /// 获取MongoDB的集合对象 /// </summary> /// <param name="tableName">表名称</param> /// <returns>存在返回集合对象;否则返回null</returns> public static IMongoCollection <BsonDocument> GetMongoCollectionForNoType(String tableName) { INoSqlProvider provider = NoSqlManager.Create(Common.Utils.Const.AppCode); IMongoCollection <BsonDocument> collection = provider.GetCollection <BsonDocument, IMongoCollection <BsonDocument> >(tableName); if (collection == null) { throw new SystemException(String.Format("获取信息登记模型MongoDB集合失败。CollectionName:{0}", tableName)); } return(collection); }