feat: initial solution with HrynCo.DAL.Abstract and HrynCo.DAL.EF

- HrynCo.DAL.Abstract: IEntity<TId>, Entity base classes, ITransaction, IUnitOfWork
- HrynCo.DAL.EF: EfRepository<TDbContext,TEntity>, EfUnitOfWork<TDbContext>, EfTransactionAdapter
- Directory.Packages.props with centralized EF Core 9.0.5 versions
- TeamCity pipeline YAMLs for general-checks and publish

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Anatolii Grynchuk
2026-05-05 18:52:18 +03:00
commit d254873172
14 changed files with 349 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
namespace HrynCo.DAL.Abstract.Entities;
[Serializable]
public abstract class Entity<TId> : IEntity<TId> where TId : struct
{
public TId Id { get; set; }
public DateTimeOffset Created { get; set; }
public DateTimeOffset? Updated { get; set; }
}
[Serializable]
public abstract class Entity : Entity<Guid>
{
protected Entity()
{
Id = Guid.NewGuid();
Created = DateTimeOffset.UtcNow;
}
protected Entity(Guid id)
{
Id = id;
Created = DateTimeOffset.UtcNow;
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace HrynCo.DAL.Abstract.Entities;
public interface IEntity<TId> where TId : struct
{
TId Id { get; set; }
DateTimeOffset Created { get; set; }
DateTimeOffset? Updated { get; set; }
}
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>HrynCo.DAL.Abstract</RootNamespace>
<PackageId>HrynCo.DAL.Abstract</PackageId>
<Authors>HrynCo</Authors>
<Description>Abstract DAL contracts for HrynCo applications: entities, repository and unit-of-work interfaces.</Description>
<PackageTags>hrynco dal abstract entity repository unitofwork</PackageTags>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://gitea.grynco.com.ua/hrynco/hrynco-ef.git</RepositoryUrl>
</PropertyGroup>
</Project>
+7
View File
@@ -0,0 +1,7 @@
namespace HrynCo.DAL.Abstract;
public interface ITransaction : IAsyncDisposable
{
Task CommitAsync(CancellationToken cancellationToken = default);
Task RollbackAsync(CancellationToken cancellationToken = default);
}
+11
View File
@@ -0,0 +1,11 @@
namespace HrynCo.DAL.Abstract;
public interface IUnitOfWork
{
Task SaveChangesAsync(CancellationToken cancellationToken = default);
Task<ITransaction> BeginTransactionAsync(CancellationToken cancellationToken = default);
ITransaction? GetCurrentTransaction();
Task ExecuteInTransactionAsync(Func<Task> action);
Task<TResult> ExecuteInTransactionAsync<TResult>(Func<Task<TResult>> action);
}