diff --git a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
index 37aad3f..dfc8865 100644
--- a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
+++ b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
@@ -17,9 +17,9 @@
http://git.dd:3000/AppStd/WebCoreModules.git
False
core_icon.png
- 3.4.0
- 3.4.0
- 3.4.0
+ 3.4.1
+ 3.4.1
+ 3.4.1
diff --git a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs
index a452a81..c5562ff 100644
--- a/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs
+++ b/DigitalData.Core.Abstractions/Infrastructure/ICRUDRepository.cs
@@ -5,7 +5,6 @@
///
/// The type of the entity this repository works with.
/// The type of the identifier for the entity.
- [Obsolete("ICRUDRepository has been deprecated. Please use the IRepository interface instead, which provides a better abtraction (e.g. without tracking) and flexibility.")]
public interface ICRUDRepository where TEntity : class, IUnique
{
///
diff --git a/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs
index f6265f1..5d748bc 100644
--- a/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs
+++ b/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs
@@ -4,13 +4,13 @@ namespace DigitalData.Core.Abstractions.Infrastructure;
public interface IRepository
{
- public Task CreateAsync(TEntity dto, CancellationToken ct = default);
+ public Task CreateAsync(TEntity entity, CancellationToken ct = default);
- public Task CreateAsync(IEnumerable dtos, CancellationToken ct = default);
+ public Task> CreateAsync(IEnumerable entities, CancellationToken ct = default);
- public Task> ReadAsync(Expression? expression = null, CancellationToken ct = default);
+ public Task> ReadAsync(Expression>? expression = null, CancellationToken ct = default);
- public Task> UpdateAsync(TDto dto, Expression expression, CancellationToken ct = default);
+ public Task UpdateAsync(TUpdate update, Expression> expression, CancellationToken ct = default);
- public Task> DeleteAsync(Expression expression, CancellationToken ct = default);
+ public Task DeleteAsync(Expression> expression, CancellationToken ct = default);
}
diff --git a/DigitalData.Core.Application/DigitalData.Core.Application.csproj b/DigitalData.Core.Application/DigitalData.Core.Application.csproj
index 62c5ef6..04ace75 100644
--- a/DigitalData.Core.Application/DigitalData.Core.Application.csproj
+++ b/DigitalData.Core.Application/DigitalData.Core.Application.csproj
@@ -1,4 +1,4 @@
-
+
net7.0;net8.0;net9.0
@@ -14,9 +14,9 @@
core_icon.png
http://git.dd:3000/AppStd/WebCoreModules.git
digital data core application clean architecture
- 3.2.0
- 3.2.0
- 3.2.0
+ 3.2.1
+ 3.2.1
+ 3.2.1
diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs
index 3139ddc..67b4480 100644
--- a/DigitalData.Core.Infrastructure/DbRepository.cs
+++ b/DigitalData.Core.Infrastructure/DbRepository.cs
@@ -5,13 +5,13 @@ using System.Linq.Expressions;
namespace DigitalData.Core.Infrastructure;
-internal class DbRepository : IRepository where TDbContext : DbContext where TEntity : class
+public class DbRepository : IRepository where TDbContext : DbContext where TEntity : class
{
- protected readonly TDbContext Context;
+ protected internal readonly TDbContext Context;
- protected readonly DbSet Entities;
+ protected internal readonly DbSet Entities;
- protected readonly IMapper Mapper;
+ protected internal readonly IMapper Mapper;
public DbRepository(TDbContext context, Func> queryFactory, IMapper mapper)
{
@@ -20,28 +20,47 @@ internal class DbRepository : IRepository where TD
Mapper = mapper;
}
- public virtual Task CreateAsync(TEntity entity, CancellationToken ct = default)
+ public virtual async Task CreateAsync(TEntity entity, CancellationToken ct = default)
{
- throw new NotImplementedException();
+ Entities.Add(entity);
+ await Context.SaveChangesAsync(ct);
+ return entity;
}
- public virtual Task CreateAsync(IEnumerable entities, CancellationToken ct = default)
+ public virtual async Task> CreateAsync(IEnumerable entities, CancellationToken ct = default)
{
- throw new NotImplementedException();
+ Entities.AddRange(entities);
+ await Context.SaveChangesAsync(ct);
+ return entities;
}
- public virtual Task> DeleteAsync(Expression expression, CancellationToken ct = default)
+ public virtual async Task> ReadAsync(Expression>? expression = null, CancellationToken ct = default)
+ => expression is null
+ ? await Entities.AsNoTracking().ToListAsync(ct)
+ : await Entities.AsNoTracking().Where(expression).ToListAsync(ct);
+
+ public virtual async Task UpdateAsync(TUpdate update, Expression> expression, CancellationToken ct = default)
{
- throw new NotImplementedException();
+ var entities = await Entities.Where(expression).ToListAsync(ct);
+
+ foreach (var entity in entities)
+ {
+ Mapper.Map(update, entity);
+ Entities.Add(entity);
+ }
+
+ await Context.SaveChangesAsync(ct);
}
- public virtual Task> ReadAsync(Expression? expression = null, CancellationToken ct = default)
+ public virtual async Task DeleteAsync(Expression> expression, CancellationToken ct = default)
{
- throw new NotImplementedException();
- }
+ var entities = await Entities.Where(expression).ToListAsync(ct);
- public virtual Task> UpdateAsync(TDto dto, Expression expression, CancellationToken ct = default)
- {
- throw new NotImplementedException();
+ foreach (var entity in entities)
+ {
+ entities.Remove(entity);
+ }
+
+ await Context.SaveChangesAsync(ct);
}
}
diff --git a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
index ee57785..da03111 100644
--- a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
+++ b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
@@ -1,4 +1,4 @@
-
+
net7.0;net8.0;net9.0
@@ -6,7 +6,7 @@
enable
True
DigitalData.Core.Infrastructure
- 2.0.0.0
+ 2.0.1
Digital Data GmbH
Digital Data GmbH
DigitalData.Core.Infrastructure