public OcelotConfigDbDal(OcelotConfigDbConfiguration configDbConfiguration)
 {
     _dbConnectionString    = configDbConfiguration.ConnectionString;
     _ocelotConfigTableName = configDbConfiguration.ConfigTableName;
     _sqlQueryAllConfig     = $"SELECT `Id`,`Section`,`Payload`,`CreateTime`,`LastUpdate` FROM {_ocelotConfigTableName}";
     _sqlQueryBySection     = $"SELECT * FROM {_ocelotConfigTableName} Where Section=@Section;";
     _sqlInsert             = $"INSERT INTO{_ocelotConfigTableName}(`Section`,`Payload`,`CreateTime`,`LastUpdate`)VALUES(@Section, @Payload, @CreateTime, @LastUpdate)";
     _sqlUpdate             = $"UPDATE {_ocelotConfigTableName} SET `Section` = @Section,`Payload` = @Payload,`LastUpdate` = @LastUpdate WHERE Id=@Id";
 }
Пример #2
0
        public static IOcelotBuilder AddConfigStoredInMySql(this IOcelotBuilder builder, Action <OcelotConfigDbConfiguration> ocelotCfgDbOptions)
        {
            var options = new OcelotConfigDbConfiguration();

            builder.Services.AddSingleton(options);
            ocelotCfgDbOptions?.Invoke(options);

            builder.Services.AddSingleton(MySqlMiddlewareConfigurationProvider.Get);
            builder.Services.AddSingleton <IFileConfigurationRepository, MySqlFileConfigurationRepository>();
            builder.Services.AddSingleton <IOcelotCache <FileConfiguration>, OcelotConfigCache>();
            builder.Services.AddSingleton(typeof(OcelotConfigDbDal), new OcelotConfigDbDal(options));
            builder.Services.Remove(new ServiceDescriptor(typeof(IFileConfigurationRepository), typeof(DiskFileConfigurationRepository)));
            return(builder);
        }