public MaxscaleDbcontextFixture()
        {
            var containerBuilder = new ContainerBuilder();
            //maxscale连接地址
            //var dbstring = "Server=106.14.139.201;Port=14006;database=adnc_cus;uid=adnc;pwd=123abc;";
            var dbstring = "server=106.14.139.201;port=14006;user=adnc;password=123abc;database=adnc_cus";

            //注册操作用户
            containerBuilder.RegisterType <Operater>()
            .As <IOperater>()
            .InstancePerLifetimeScope();

            //注册DbContext Options
            var serverVersion = new MariaDbServerVersion(new Version(10, 5, 4));

            containerBuilder.Register <DbContextOptions>(c =>
            {
                var options = new DbContextOptionsBuilder <AdncDbContext>()
                              .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddDebug()))
                              .UseMySql(dbstring, serverVersion, mySqlOptions =>
                {
                })
                              .AddInterceptors(new DefaultDbCommandInterceptor())
                              .Options;
                return(options);
            }).InstancePerLifetimeScope();

            //注册EntityInfo
            containerBuilder.RegisterType <EntityInfo>()
            .As <IEntityInfo>()
            .InstancePerLifetimeScope();

            //注册DbContext
            containerBuilder.RegisterType <AdncDbContext>()
            .InstancePerLifetimeScope();

            //注册Adnc.Infra.EfCore
            AdncCusRepositoryModule.Register(containerBuilder);

            Container = containerBuilder.Build();
        }
Exemple #2
0
        public CoreServiceFixture()
        {
            var containerBuilder = new ContainerBuilder();

            var dbstring = "Server=106.14.139.201;Port=13308;database=adnc_cus_dev;uid=root;pwd=alpha.netcore;";

            //注册操作用户
            containerBuilder.RegisterType <Operater>()
            .As <IOperater>()
            .InstancePerLifetimeScope();

            //注册DbContext Options
            containerBuilder.Register <DbContextOptions>(c =>
            {
                var serverVersion = new MariaDbServerVersion(new Version(10, 5, 4));

                return(new DbContextOptionsBuilder <AdncDbContext>()
                       .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddDebug()))
                       .UseMySql(dbstring, serverVersion).Options);
            })
            .InstancePerLifetimeScope();

            //注册DbContext
            containerBuilder.RegisterType <AdncDbContext>().InstancePerLifetimeScope();

            //注册事件发布者
            containerBuilder.RegisterType <NullCapPublisher>()
            .As <ICapPublisher>().SingleInstance();

            //注册Adnc.Infra.EfCore
            AdncInfraEfCoreModule.Register(containerBuilder);

            //注册 Adnc.Cus.Core
            AdncCusRepositoryModule.Register(containerBuilder);

            Container = containerBuilder.Build();
        }