public MySqlEventVersionStore(MySqlOptions options) { connectionString = options.ConnectionString; schema = options.Schema; tableName = options.EventVersionTableName; tableCount = options.EventVersionTableCount; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddScoped <IProductRepository, SqlProductRepository>(); services.AddScoped <ISaleRepository, SqlSaleRepository>(); services.AddScoped <ISaledetailRepository, SqlSaledetailRepository>(); services.AddScoped <IAdminRepository, SqlAdminRepository>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { //登录路径:这是当用户试图访问资源但未经过身份验证时,程序将会将请求重定向到这个相对路径 o.LoginPath = new PathString("/Account/Login"); //禁止访问路径:当用户试图访问资源时,但未通过该资源的任何授权策略,请求将被重定向到这个相对路径。 o.AccessDeniedPath = new PathString("/Home/Index"); }); //MySql string connectionsString = _configuration.GetConnectionString("MySqlConnection"); services.AddDbContextPool <jquerytestContext>(options => options.UseMySql(connectionsString, MySqlOptions => MySqlOptions.ServerVersion("8.0.21-mysql"))); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContext <nhrappdataContext>(options => { options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), mySqlOptionsAction: MySqlOptions => { MySqlOptions.EnableRetryOnFailure( maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); }); }); services.AddTransient <IRepository <Employee>, EmployeeRepository>(); // Register the Swagger generator services.AddSwaggerGen(c => { c.SwaggerDoc( "v1", new Info { Title = "My API", Version = "v1" }); }); }
private static void AddConfigurationServices(IServiceCollection services) { services.AddSingleton(configuration); services.AddSingleton <TeamsConfiguration>(ctx => { var t = new TeamsConfiguration(); configuration.Bind("Teams", t); return(t); }); services.AddSingleton <BackupOptions>(ctx => { var t = new BackupOptions(); configuration.Bind("Backup", t); return(t); }); services.AddSingleton <MySqlOptions>(ctx => { var t = new MySqlOptions(); configuration.Bind("MySql", t); return(t); }); services.AddSingleton <RetentionOptions>(ctx => { var t = new RetentionOptions(); configuration.Bind("Retention", t); return(t); }); services.AddSingleton <SlackConfiguration>(ctx => { var t = new SlackConfiguration(); configuration.Bind("Slack", t); return(t); }); services.AddSingleton <AzureConfiguration>(ctx => { var t = new AzureConfiguration(); configuration.Bind("Azure", t); return(t); }); services.AddSingleton <S3Configuration>(ctx => { var t = new S3Configuration(); configuration.Bind("S3", t); return(t); }); services.AddSingleton <PhysicalConfiguration>(ctx => { var t = new PhysicalConfiguration(); configuration.Bind("Physical", t); return(t); }); }
private static MySqlTypeMappingSource GetMapper(MySqlOptions options = null) => new MySqlTypeMappingSource( new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), Array.Empty <ITypeMappingSourcePlugin>()), new RelationalTypeMappingSourceDependencies( Array.Empty <IRelationalTypeMappingSourcePlugin>()), options ?? new MySqlOptions());
public MySqlEventStore(IStringObjectSerializer objectSerializer, MySqlOptions options) { this.objectSerializer = objectSerializer; connectionString = options.ConnectionString; schema = options.Schema; tableName = options.EventTableName; tableCount = options.EventTableCount; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContextPool <ApplicationContext>(options => options .UseMySql(Configuration.GetConnectionString("ApplicationDatabase"), MySqlOptions => MySqlOptions .ServerVersion(new Version(8, 0, 20), ServerType.MySql) )); services.AddControllers(); }
public void UseMySql_without_connection_string() { var builder = new DbContextOptionsBuilder(); var serverVersion = ServerVersion.AutoDetect(AppConfig.ConnectionString); builder.UseMySql(serverVersion); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); }
private static MySqlOptions GetOptions(Action <MySqlDbContextOptionsBuilder> builder) { var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize( new DbContextOptionsBuilder() .UseMySql("Server=foo", builder) .Options); return(mySqlOptions); }
public void TreatTinyAsBoolean_false() { var builder = new DbContextOptionsBuilder(); builder.UseMySql("TreatTinyAsBoolean=False"); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(MySqlBooleanType.Bit1, mySqlOptions.DefaultDataTypeMappings.ClrBoolean); }
private static string GetHostName(MySqlOptions mysqlOptions) { try { var connectionStringBuilder = new MySqlConnectionStringBuilder(mysqlOptions.ConnectionString); return(connectionStringBuilder.Server); } catch { return("CANNOTRESOLVEHOSTNAME"); } }
public void TreatTinyAsBoolean_unspecified() { var builder = new DbContextOptionsBuilder(); builder.UseMySql("Server=foo", AppConfig.ServerVersion); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(MySqlBooleanType.Default, mySqlOptions.DefaultDataTypeMappings.ClrBoolean); }
/// <summary> /// 策略 使用Mysql存储 /// </summary> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddMySqlPolicyStore(this IServiceCollection services, Action <MySqlOptions> options) { var opts = new MySqlOptions(); options.Invoke(opts); if (string.IsNullOrWhiteSpace(opts.ConnectionString)) { throw new ArgumentException("策略存储,缺少MySql连接字符串"); } services.AddSingleton(opts); services.AddSingleton <IPolicyStore, MySqlPolicyStore>(); return(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContextPool <TodoContext>(opt => opt .UseMySql("Server=localhost;Database=todo;User=root;Convert Zero Datetime=True", MySqlOptions => MySqlOptions .ServerVersion(new Version(10, 4, 6), ServerType.MariaDb) ) ); services.AddCors(opt => opt.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader())); }
protected override IUpdateSqlGenerator CreateSqlGenerator() { var options = new MySqlOptions(); return(new MySqlUpdateSqlGenerator( new UpdateSqlGeneratorDependencies( new MySqlSqlGenerationHelper( new RelationalSqlGenerationHelperDependencies(), options), new MySqlTypeMappingSource( TestServiceFactory.Instance.Create <TypeMappingSourceDependencies>(), TestServiceFactory.Instance.Create <RelationalTypeMappingSourceDependencies>(), options)))); }
public void Explicit_DefaultDataTypeMappings_take_precedence_over_TreatTinyAsBoolean_false() { var builder = new DbContextOptionsBuilder(); builder.UseMySql( "TreatTinyAsBoolean=False", b => b.DefaultDataTypeMappings(m => m.WithClrBoolean(MySqlBooleanType.TinyInt1))); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(MySqlBooleanType.TinyInt1, mySqlOptions.DefaultDataTypeMappings.ClrBoolean); }
public void UseMySql_without_connection_explicit_DefaultDataTypeMappings_is_applied() { var builder = new DbContextOptionsBuilder(); builder.UseMySql( AppConfig.ServerVersion, b => b.DefaultDataTypeMappings(m => m.WithClrBoolean(MySqlBooleanType.Bit1))); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(MySqlBooleanType.Bit1, mySqlOptions.DefaultDataTypeMappings.ClrBoolean); }
private static void MigrateToLatest <TKey>(string connectionString, IdentityOptionsExtended identityOptions, MySqlOptions options) where TKey : IEquatable <TKey> { var runner = new MigrationRunner(connectionString, options); if (identityOptions.Stores.CreateIfNotExists) { runner.CreateDatabaseIfNotExistsAsync(CancellationToken.None).Wait(); } if (identityOptions.Stores.MigrateOnStartup) { runner.MigrateUp(CancellationToken.None); } }
public void UseMySql_with_MariaDbServerVersion_LatestSupportedServerVersion() { var builder = new DbContextOptionsBuilder(); builder.UseMySql( "Server=foo", MariaDbServerVersion.LatestSupportedServerVersion); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(MariaDbServerVersion.LatestSupportedServerVersion.Version, mySqlOptions.ServerVersion.Version); Assert.Equal(ServerType.MariaDb, mySqlOptions.ServerVersion.Type); Assert.Equal("mariadb", mySqlOptions.ServerVersion.TypeIdentifier); }
public void UseMySql_with_MariaDbServerVersion_ServerVersion() { var builder = new DbContextOptionsBuilder(); builder.UseMySql( "Server=foo", new MariaDbServerVersion(new MariaDbServerVersion(new Version(10, 5, 5)))); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(new Version(10, 5, 5), mySqlOptions.ServerVersion.Version); Assert.Equal(ServerType.MariaDb, mySqlOptions.ServerVersion.Type); Assert.Equal("mariadb", mySqlOptions.ServerVersion.TypeIdentifier); }
public void UseMySql_with_MySqlServerVersion_ServerVersion() { var builder = new DbContextOptionsBuilder(); builder.UseMySql( "Server=foo", new MySqlServerVersion(new MySqlServerVersion(new Version(8, 0, 21)))); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(new Version(8, 0, 21), mySqlOptions.ServerVersion.Version); Assert.Equal(ServerType.MySql, mySqlOptions.ServerVersion.Type); Assert.Equal("mysql", mySqlOptions.ServerVersion.TypeIdentifier); }
public void UseMySql_with_ServerVersion_AutoDetect() { var builder = new DbContextOptionsBuilder(); var serverVersion = ServerVersion.AutoDetect(AppConfig.ConnectionString); builder.UseMySql( "Server=foo", serverVersion); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(serverVersion.Version, mySqlOptions.ServerVersion.Version); Assert.Equal(serverVersion.Type, mySqlOptions.ServerVersion.Type); Assert.Equal(serverVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier); }
public void UseMySql_with_ServerVersion_FromString() { var builder = new DbContextOptionsBuilder(); var serverVersion = ServerVersion.Parse("8.0.21-mysql"); builder.UseMySql( "Server=foo", serverVersion); var mySqlOptions = new MySqlOptions(); mySqlOptions.Initialize(builder.Options); Assert.Equal(new Version(8, 0, 21), mySqlOptions.ServerVersion.Version); Assert.Equal(ServerType.MySql, mySqlOptions.ServerVersion.Type); Assert.Equal("mysql", mySqlOptions.ServerVersion.TypeIdentifier); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContextPool <MyDbContext>(options => { options.UseMySql( Configuration["Data:WordCard:ConnectionString"], MySqlOptions => { MySqlOptions.ServerVersion(new Version(10, 1, 38), ServerType.MariaDb); } ); }); services.AddTransient <IWordRepository, EFWordRepo>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(Options => { Options.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); }); // services.AddDbContext<TodoContext>(opt => // opt.UseInMemoryDatabase("TodoList")); services.AddDbContext <TodoContext>( opt => opt.UseMySql("Server=localhost;Database=Todoef;user=root;", MySqlOptions => { MySqlOptions.ServerVersion(new Version(10, 1, 38), ServerType.MariaDb); }) ); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(c => { c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin()); }); services.AddAutoMapper(typeof(Startup)); services.AddMvc(); services.AddDbContext <heroku_4f2def07091704cContext>(options => options.UseMySql(Configuration.GetConnectionString("LocalConnection"), mySqlOptionsAction: MySqlOptions => { MySqlOptions.EnableRetryOnFailure( maxRetryCount: 4, maxRetryDelay: TimeSpan.FromSeconds(10), errorNumbersToAdd: null ); })); services.AddControllers(); services.Configure <AppSettings>(Configuration.GetSection("AppSettings")); //services.AddTokenAuthentication(Configuration); services.AddAuthentication() .AddGoogle(googleOptions => { // Đọc thông tin Authentication:Google từ appsettings.json IConfigurationSection googleAuthNSection = Configuration.GetSection("Authentication:Google"); // Thiết lập ClientID và ClientSecret để truy cập API google googleOptions.ClientId = googleAuthNSection["ClientId"]; googleOptions.ClientSecret = googleAuthNSection["ClientSecret"]; }); services.AddTransient <IRepository <Boards>, EntityRepository <Boards> >(); services.AddTransient <IBoardService, BoardService>(); services.AddTransient <IRepository <Users>, EntityRepository <Users> >(); services.AddTransient <IUserService, UserService>(); services.AddTransient <IRepository <Jobs>, EntityRepository <Jobs> >(); services.AddTransient <IJobService, JobService>(); }
public DojoFactory(IOptions <MySqlOptions> config) { _options = config.Value; }
public TrailFactory(IOptions <MySqlOptions> config) { _options = config.Value; }
private static string CodeLiteral(object value, MySqlOptions options = null) => GetCsHelper(options).UnknownLiteral(value);
private static CSharpHelper GetCsHelper(MySqlOptions options = null) => new CSharpHelper(GetMapper(options));