mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-24 22:42:53 +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;
|
|
}
|
|
}
|