feat: rebuild base repository hierarchy, add readme and agents

- 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>
This commit is contained in:
Anatolii Grynchuk
2026-05-06 01:15:59 +03:00
parent 4fac3ddba9
commit 15c58522ef
15 changed files with 750 additions and 179 deletions
+47 -3
View File
@@ -1,9 +1,47 @@
namespace HrynCo.DAL.Abstract.Entities;
[Serializable]
public abstract class Entity<TId> : IEntity<TId> where TId : struct
public interface IEntity
{
DateTimeOffset Created { get; set; }
object Id { get; set; }
DateTimeOffset? Updated { get; set; }
}
public interface IEntity<TId> : IEntity where TId : struct
{
new TId Id { get; set; }
}
[Serializable]
public class Entity<TId> : IEntity<TId> where TId : struct
{
protected Entity()
{
}
public Entity(TId id)
{
Id = id;
}
public TId Id { get; set; }
object IEntity.Id
{
get => Id;
set
{
if (value is TId typedValue)
{
Id = typedValue;
}
else
{
throw new InvalidCastException($"Cannot cast value of type {value.GetType()} to {typeof(TId)}.");
}
}
}
public DateTimeOffset Created { get; set; }
public DateTimeOffset? Updated { get; set; }
}
@@ -17,7 +55,13 @@ public abstract class Entity : Entity<Guid>
}
protected Entity(Guid id)
: base(id)
{
Id = id;
}
}
[Serializable]
public abstract class NamedEntity : Entity
{
public required string Name { get; set; }
}
-12
View File
@@ -1,12 +0,0 @@
namespace HrynCo.DAL.Abstract.Entities;
public interface IEntity
{
DateTimeOffset Created { get; set; }
DateTimeOffset? Updated { get; set; }
}
public interface IEntity<TId> : IEntity where TId : struct
{
TId Id { get; set; }
}
+3 -1
View File
@@ -1,8 +1,10 @@
namespace HrynCo.DAL.Abstract;
using System.Threading;
using System.Threading.Tasks;
public interface IUnitOfWork
{
Task SaveChangesAsync(CancellationToken cancellationToken = default);
Task<ITransaction> BeginTransactionAsync(CancellationToken cancellationToken = default);
ITransaction? GetCurrentTransaction();
+9
View File
@@ -0,0 +1,9 @@
namespace HrynCo.DAL.Abstract;
public sealed class PagedResult<T>
{
public required IReadOnlyList<T> Items { get; init; }
public required int Page { get; init; }
public required int PageSize { get; init; }
public required int TotalCount { get; init; }
}