15c58522ef
- replace EfRepository/BaseDbContext/UtcValueConverter with BaseEfRepository and BaseRepository - add IEfRepository interface hierarchy - consolidate IEntity into Entity.cs, remove standalone IEntity.cs - add PagedResult - adjust all namespaces to HrynCo.DAL.Abstract / HrynCo.DAL.EF - add README.md with solution overview, versioning rules, class diagram - add AGENTS.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 lines
887 B
C#
26 lines
887 B
C#
namespace HrynCo.DAL.EF.Core;
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using HrynCo.DAL.Abstract.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
[SuppressMessage("Major Code Smell", "S2436:Reduce the number of generic parameters",
|
|
Justification = "Generic design is intentional and improves reusability")]
|
|
public abstract class BaseRepository<TEfRepository, TDbContext, TEntity, TEntityId>
|
|
where TEntity : class, IEntity<TEntityId>
|
|
where TDbContext : DbContext
|
|
where TEfRepository : BaseEfRepository<TDbContext, TEntity, TEntityId>
|
|
where TEntityId : struct
|
|
{
|
|
private readonly Lazy<TEfRepository> _lazyEfRepository;
|
|
|
|
protected BaseRepository()
|
|
{
|
|
_lazyEfRepository = new Lazy<TEfRepository>(CreateEfRepository);
|
|
}
|
|
|
|
protected TEfRepository EfRepository => _lazyEfRepository.Value;
|
|
|
|
protected abstract TEfRepository CreateEfRepository();
|
|
}
|