26 lines
708 B
C#
26 lines
708 B
C#
namespace FiscalOS.API.Data;
|
|||
|
|
|
||
|
|
internal sealed record AppDbContextOptions
|
||
|
|
{
|
||
|
|
public string DatabaseFilePath { get; init; } = string.Empty;
|
||
|
|
public string GetFullyQualifiedDatabasePath()
|
||
|
|
{
|
||
|
|
return Path.GetFullPath(DatabaseFilePath, AppContext.BaseDirectory);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed record AppDbContextOptionsSetup : IConfigureOptions<AppDbContextOptions>
|
||
|
|
{
|
||
|
|
private const string SectionName = nameof(AppDbContextOptions);
|
||
|
|
private readonly IConfiguration _configuration;
|
||
|
|
|
||
|
|
public AppDbContextOptionsSetup(IConfiguration configuration)
|
||
|
|
{
|
||
|
|
_configuration = configuration;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Configure(AppDbContextOptions options)
|
||
|
|
{
|
||
|
|
_configuration.GetSection(SectionName).Bind(options);
|
||
|
|
}
|
||
|
|
}
|