1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-11-23 10:42:51 +01:00
Minecraft-Phantom-Panel/Controller/Phantom.Controller.Database.Postgres/LazyDbContext.cs
2023-12-05 14:27:55 +01:00

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;
}
}