Ejemplo n.º 1
0
        public DemoDatabseUnitofwork(ILoggerFactory logger, IVPD <BSiteContext> virtualPrivateDatabase)
        {
            var optionsBuilder = new DbContextOptionsBuilder <BSiteContext>();

            optionsBuilder.UseLoggerFactory(logger);
            optionsBuilder.UseSqlServer(Core.Infrastructure.Global.DBRWManager.GetMaster(optionsBuilder.Options.ContextType.ToString()));//默认设置为主,查询的时候会自动转到从
            optionsBuilder.UseNoLockSqlGenerator();
            base.DbContext = new BSiteContext(optionsBuilder.Options);
            virtualPrivateDatabase?.SetVPD(base.DbContext);
        }
Ejemplo n.º 2
0
        public MiniProgramDatabaseUniofwork(ILoggerFactory logger, IVPD <WXContext> virtualPrivateDatabase)
        {
            var optionsBuilder = new DbContextOptionsBuilder <WXContext>();

            optionsBuilder.UseLoggerFactory(logger);
            optionsBuilder.UseSqlServer(Core.Infrastructure.Global.DBRWManager.GetMaster(optionsBuilder.Options.ContextType.ToString()));//默认设置为主,查询的时候会自动转到从
            //optionsBuilder.EnableSensitiveDataLogging();

            optionsBuilder.UseNoLockSqlGenerator();
            base.DbContext = new WXContext(optionsBuilder.Options);
            virtualPrivateDatabase?.SetVPD(base.DbContext);
        }