Чето поменял

This commit is contained in:
2025-03-08 22:00:08 +03:00
parent b4056fa715
commit 8c0ad9bc3e
30 changed files with 584 additions and 566 deletions

View File

@@ -0,0 +1,39 @@
using System.Reflection;
using ApplicationLayer.InfrastructureServicesInterfaces;
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database;
public class DatabaseContext(DbContextOptions<DatabaseContext> opts) : DbContext(opts), IGenericWriter, IGenericReader, IUnitOfWork
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
}
async Task IGenericWriter.AddAsync<T>(T entity, CancellationToken cancellationToken)
{
await AddAsync(entity, cancellationToken);
}
void IGenericWriter.Update<T>(T entity)
{
Update(entity);
}
void IGenericWriter.Remove<T>(T entity)
{
Remove(entity);
}
IQueryable<T> IGenericReader.GetAll<T>()
{
return Set<T>();
}
async Task IUnitOfWork.SaveAsync(CancellationToken cancellationToken)
{
await SaveChangesAsync(cancellationToken);
}
}