mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-12-22 16:42:50 +01:00
17 lines
507 B
C#
17 lines
507 B
C#
namespace Phantom.Controller.Database.Postgres;
|
|
|
|
sealed class LazyDbContext : ILazyDbContext {
|
|
public ApplicationDbContext Ctx => cachedContext ??= contextFactory.Eager();
|
|
|
|
private readonly ApplicationDbContextFactory contextFactory;
|
|
private ApplicationDbContext? cachedContext;
|
|
|
|
internal LazyDbContext(ApplicationDbContextFactory contextFactory) {
|
|
this.contextFactory = contextFactory;
|
|
}
|
|
|
|
public ValueTask DisposeAsync() {
|
|
return cachedContext?.DisposeAsync() ?? ValueTask.CompletedTask;
|
|
}
|
|
}
|