Beispiel #1
0
        public static int ExecuteNonQuery(DataBaseEnum dbName, string strCommand, CommandType commandType,
                                          List <dbParam> listParam)
        {
            string connName = dbName.ToString();

            return(ExecuteNonQuery(connName, strCommand, commandType, listParam));
        }
Beispiel #2
0
        public static IDataReader ExecuteDataReader(DataBaseEnum dbName, string strCommand, CommandType commandType,
                                                    List <dbParam> listParam)
        {
            string connName = dbName.ToString();

            return(ExecuteDataReader(connName, strCommand, commandType, listParam));
        }
Beispiel #3
0
        public static Database GetDataBase(DataBaseEnum dbName)
        {
            string   connName = dbName.ToString();
            Database db       = DatabaseFactory.CreateDatabase(connName);

            return(db);
        }
Beispiel #4
0
        public string GetConnectionString(DataBaseEnum dataBase)
        {
            switch (dataBase)
            {
            case DataBaseEnum.Northwind:
                this._connectionString = ConnectionString.NorthwindConnectionString;
                break;
                //TODO:Add other case
            }
            if (string.IsNullOrWhiteSpace(_connectionString))
            {
                throw new ArgumentNullException(nameof(_connectionString));
            }

            return(_connectionString);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="services"></param>
        /// <param name="type"></param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns></returns>
        public static IServiceCollection AddRabbitMQ(this IServiceCollection services, DataBaseEnum type, string connString)
        {
            switch (type)
            {
            case DataBaseEnum.Mysql:
                services.AddSingleton(typeof(IMessageQueueHelper), _ => new Common.LightMessager.DAL.Mysql.MessageQueueHelper(connString));
                break;

            case DataBaseEnum.SqlServer:
                services.AddSingleton(typeof(IMessageQueueHelper), _ => new Common.LightMessager.DAL.SqlServer.MessageQueueHelper(connString));
                break;

            case DataBaseEnum.Oracle:
                services.AddSingleton(typeof(IMessageQueueHelper), _ => new Common.LightMessager.DAL.Oracle.MessageQueueHelper(connString));
                break;

            default:
                throw new NotSupportedException("RabbitMQ 封装类暂不支持Mysql,SqlServer,Oralce以外的数据库。");
            }

            services.AddSingleton <IRabbitMQProducer, RabbitMQProducer>();

            return(services);
        }