@@ -83,61 +83,22 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
8383 }
8484 services . AddSingleton < ConfigService > ( ) ;
8585
86- string acid = "" ;
87- if ( environmentVariables . Contains ( "acid" ) )
86+ if ( bdType . Equals ( "0" ) )
8887 {
89- acid = environmentVariables [ "acid" ] as string ;
88+ services . AddDbContext < EntityContext > ( ) ;
89+ services . AddDbContext < EntityContextBASE > ( ) ;
9090 }
91- else
91+ else if ( bdType . Equals ( "1" ) )
9292 {
93- acid = configuration . GetConnectionString ( "acid" ) ;
93+ services . AddDbContext < EntityContext , EntityContextOracle > ( ) ;
94+ services . AddDbContext < EntityContextBASE , EntityContextBASEOracle > ( ) ;
9495 }
95- string baseConnection = "" ;
96- if ( environmentVariables . Contains ( "base" ) )
96+ else if ( bdType . Equals ( "2" ) )
9797 {
98- baseConnection = environmentVariables [ "base" ] as string ;
98+ services . AddDbContext < EntityContext , EntityContextPostgres > ( ) ;
99+ services . AddDbContext < EntityContextBASE , EntityContextBASEPostgres > ( ) ;
99100 }
100- else
101- {
102- baseConnection = configuration . GetConnectionString ( "base" ) ;
103- }
104- if ( bdType . Equals ( "0" ) )
105- {
106- services . AddDbContext < EntityContext > ( options =>
107- options . UseSqlServer ( acid , o => o . UseCompatibilityLevel ( 110 ) )
108- ) ;
109- services . AddDbContext < EntityContextBASE > ( options =>
110- options . UseSqlServer ( baseConnection , o => o . UseCompatibilityLevel ( 110 ) )
111101
112- ) ;
113- }
114- else if ( bdType . Equals ( "1" ) )
115- {
116- services . AddDbContext < EntityContext , EntityContextOracle > ( options =>
117- options . UseOracle ( acid )
118- ) ;
119- services . AddDbContext < EntityContextBASE , EntityContextBASEOracle > ( options =>
120- options . UseOracle ( baseConnection )
121-
122- ) ;
123- }
124- else if ( bdType . Equals ( "2" ) )
125- {
126- services . AddDbContext < EntityContext , EntityContextPostgres > ( opt =>
127- {
128- var builder = new NpgsqlDbContextOptionsBuilder ( opt ) ;
129- builder . SetPostgresVersion ( new Version ( 9 , 6 ) ) ;
130- opt . UseNpgsql ( acid ) ;
131-
132- } ) ;
133- services . AddDbContext < EntityContextBASE , EntityContextBASEPostgres > ( opt =>
134- {
135- var builder = new NpgsqlDbContextOptionsBuilder ( opt ) ;
136- builder . SetPostgresVersion ( new Version ( 9 , 6 ) ) ;
137- opt . UseNpgsql ( baseConnection ) ;
138-
139- } ) ;
140- }
141102 services . AddHostedService < CacheRefreshWorker > ( ) ;
142103 } ) ;
143104 }
0 commit comments