|
4 | 4 | using TCDev.APIGenerator.Extension; |
5 | 5 | using TCDev.APIGenerator.Model.Interfaces; |
6 | 6 |
|
7 | | -namespace TCDev.APIGenerator.SQL; |
| 7 | +namespace TCDev.APIGenerator.Data.Postgres; |
8 | 8 |
|
9 | | -public static partial class ServiceExtension |
| 9 | +public class ProviderConfig : IDatabaseProviderConfiguration |
10 | 10 | { |
11 | | - public class ProviderConfig : IDatabaseProviderConfiguration |
| 11 | + private IConfiguration configuration; |
| 12 | + private ApiGeneratorServiceBuilder builder; |
| 13 | + public ProviderConfig(IConfiguration config, ApiGeneratorServiceBuilder builder) |
12 | 14 | { |
13 | | - private IConfiguration configuration; |
14 | | - private ApiGeneratorServiceBuilder builder; |
15 | | - public ProviderConfig(IConfiguration config, ApiGeneratorServiceBuilder builder) |
16 | | - { |
17 | | - this.configuration = config; |
18 | | - this.builder = builder; |
19 | | - } |
| 15 | + this.configuration = config; |
| 16 | + this.builder = builder; |
| 17 | + } |
20 | 18 |
|
21 | | - public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |
22 | | - { |
23 | | - if (string.IsNullOrEmpty(builder.ApiGeneratorConfig.DatabaseOptions.Connection) |
24 | | - && |
25 | | - string.IsNullOrEmpty(builder.ApiGeneratorConfig.DatabaseOptions.ConnectionStringName) |
26 | | - ) throw new ArgumentException("Please set either Connection or ConnectonStringName, (and not both!)"); |
| 19 | + public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |
| 20 | + { |
| 21 | + if (string.IsNullOrEmpty(builder.ApiGeneratorConfig.DatabaseOptions.Connection) |
| 22 | + && |
| 23 | + string.IsNullOrEmpty(builder.ApiGeneratorConfig.DatabaseOptions.ConnectionStringName) |
| 24 | + ) throw new ArgumentException("Please set either Connection or ConnectonStringName, (and not both!)"); |
27 | 25 |
|
28 | | - var connection = !string.IsNullOrEmpty(builder.ApiGeneratorConfig.DatabaseOptions.ConnectionStringName) ? |
29 | | - configuration.GetConnectionString(builder.ApiGeneratorConfig.DatabaseOptions.ConnectionStringName) : |
30 | | - builder.ApiGeneratorConfig.DatabaseOptions.Connection; |
| 26 | + var connection = !string.IsNullOrEmpty(builder.ApiGeneratorConfig.DatabaseOptions.ConnectionStringName) ? |
| 27 | + configuration.GetConnectionString(builder.ApiGeneratorConfig.DatabaseOptions.ConnectionStringName) : |
| 28 | + builder.ApiGeneratorConfig.DatabaseOptions.Connection; |
31 | 29 |
|
32 | 30 |
|
33 | | - optionsBuilder.UseNpgsql(connection); |
34 | | - } |
| 31 | + optionsBuilder.UseNpgsql(connection); |
35 | 32 | } |
36 | | - |
37 | 33 | } |
0 commit comments