feat: add repository layer with IUnitOfWork and fixed EF base
- ITransaction, IUnitOfWork in DAL.Abstract - EfTransactionAdapter, EfUnitOfWork<TDbContext>, NotificationUnitOfWork in DAL.EF - NotificationEfRepository<TEntity>: async-only base, fixed Exists (AnyAsync), fixed batch Add (AddRangeAsync), single SaveChangesAsync per operation - TemplateRepository, ProviderRepository, ProviderUsageRepository - ProviderUsageRepository.IncrementAsync uses atomic PostgreSQL upsert - ProviderRepository deserializes settings polymorphically via ProviderType discriminator Ref: IT-628 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace HrynCo.NotificationService.DAL.Abstract;
|
||||
|
||||
public interface ITransaction : IAsyncDisposable
|
||||
{
|
||||
Task CommitAsync(CancellationToken cancellationToken = default);
|
||||
Task RollbackAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace HrynCo.NotificationService.DAL.Abstract;
|
||||
|
||||
public interface IUnitOfWork
|
||||
{
|
||||
Task<ITransaction> BeginTransactionAsync(CancellationToken cancellationToken = default);
|
||||
ITransaction? GetCurrentTransaction();
|
||||
|
||||
Task ExecuteInTransactionAsync(Func<Task> action);
|
||||
Task<TResult> ExecuteInTransactionAsync<TResult>(Func<Task<TResult>> action);
|
||||
}
|
||||
Reference in New Issue
Block a user