diff --git a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
index dfc8865..f2236d1 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.1
- 3.4.1
- 3.4.1
+ 3.4.2
+ 3.4.2
+ 3.4.2
diff --git a/DigitalData.Core.Abstractions/Infrastructure/Extensions.cs b/DigitalData.Core.Abstractions/Infrastructure/Extensions.cs
index a7c510d..d916c85 100644
--- a/DigitalData.Core.Abstractions/Infrastructure/Extensions.cs
+++ b/DigitalData.Core.Abstractions/Infrastructure/Extensions.cs
@@ -20,15 +20,15 @@ public static class Extensions
#region Read
public static async Task ReadFirstOrDefaultAsync(this IRepository repository, Expression>? expression = null)
- => (await repository.ReadAsync(expression)).FirstOrDefault();
+ => (await repository.ReadAllAsync(expression)).FirstOrDefault();
public static async Task ReadFirstAsync(this IRepository repository, Expression>? expression = null)
- => (await repository.ReadAsync(expression)).First();
+ => (await repository.ReadAllAsync(expression)).First();
public static async Task ReadSingleOrDefaultAsync(this IRepository repository, Expression>? expression = null)
- => (await repository.ReadAsync(expression)).SingleOrDefault();
+ => (await repository.ReadAllAsync(expression)).SingleOrDefault();
public static async Task ReadSingleAsync(this IRepository repository, Expression>? expression = null)
- => (await repository.ReadAsync(expression)).Single();
+ => (await repository.ReadAllAsync(expression)).Single();
#endregion
}
diff --git a/DigitalData.Core.Abstractions/Infrastructure/IEntityMapper.cs b/DigitalData.Core.Abstractions/Infrastructure/IEntityMapper.cs
index 8f5de41..d37bf92 100644
--- a/DigitalData.Core.Abstractions/Infrastructure/IEntityMapper.cs
+++ b/DigitalData.Core.Abstractions/Infrastructure/IEntityMapper.cs
@@ -14,6 +14,14 @@
/// The mapped DTO.
TDto Map(TEntity entity);
+ ///
+ /// Maps an entity list to a DTO list.
+ ///
+ /// The type of the DTO to map to.
+ /// The entity list to be mapped.
+ /// The mapped DTO list.
+ IEnumerable Map(IEnumerable entities);
+
///
/// Maps a DTO to an entity.
///
@@ -22,6 +30,14 @@
/// The mapped entity.
TEntity Map(TDto dto);
+ ///
+ /// Maps a DTO list to an entity list.
+ ///
+ /// The type of the DTO to be mapped.
+ /// The DTO list to be mapped.
+ /// The mapped entity list.
+ IEnumerable Map(IEnumerable dtos);
+
///
/// Maps a DTO to an existing entity.
///
diff --git a/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs b/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs
index f0e72c9..c64cc02 100644
--- a/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs
+++ b/DigitalData.Core.Abstractions/Infrastructure/IRepository.cs
@@ -10,7 +10,13 @@ public interface IRepository
public Task> CreateAsync(IEnumerable entities, CancellationToken ct = default);
- public Task> ReadAsync(Expression>? expression = null, CancellationToken ct = default);
+ public Task> ReadAllAsync(Expression>? expression = null, CancellationToken ct = default);
+
+ public Task ReadOrDefaultAsync(Expression> expression, bool single = true, CancellationToken ct = default);
+
+ public Task> ReadAllAsync(Expression>? expression = null, CancellationToken ct = default);
+
+ public Task ReadOrDefaultAsync(Expression> expression, bool single = true, CancellationToken ct = default);
public Task UpdateAsync(TDto dto, Expression> expression, CancellationToken ct = default);
diff --git a/DigitalData.Core.Infrastructure.AutoMapper/DigitalData.Core.Infrastructure.AutoMapper.csproj b/DigitalData.Core.Infrastructure.AutoMapper/DigitalData.Core.Infrastructure.AutoMapper.csproj
index cdbe3bc..350ae96 100644
--- a/DigitalData.Core.Infrastructure.AutoMapper/DigitalData.Core.Infrastructure.AutoMapper.csproj
+++ b/DigitalData.Core.Infrastructure.AutoMapper/DigitalData.Core.Infrastructure.AutoMapper.csproj
@@ -6,7 +6,7 @@
enable
True
DigitalData.Core.Infrastructure.AutoMapper
- 1.0.0
+ 1.0.1
Digital Data GmbH
Digital Data GmbH
DigitalData.Core.Infrastructure.AutoMapper
@@ -16,8 +16,8 @@
http://git.dd:3000/AppStd/WebCoreModules.git
digital data core abstractions clean architecture mapping
digital data core infrastructure clean architecture mapping
- 1.0.0
- 1.0.0
+ 1.0.1
+ 1.0.1
diff --git a/DigitalData.Core.Infrastructure.AutoMapper/EntityAutoMapper.cs b/DigitalData.Core.Infrastructure.AutoMapper/EntityAutoMapper.cs
index eb6970f..b3e1106 100644
--- a/DigitalData.Core.Infrastructure.AutoMapper/EntityAutoMapper.cs
+++ b/DigitalData.Core.Infrastructure.AutoMapper/EntityAutoMapper.cs
@@ -14,7 +14,11 @@ public class EntityAutoMapper : IEntityMapper
public TDto Map(TEntity entity) => _rootMapper.Map(entity);
+ public IEnumerable Map(IEnumerable entities) => _rootMapper.Map>(entities);
+
public TEntity Map(TDto dto) => _rootMapper.Map(dto);
+ public IEnumerable Map(IEnumerable dtos) => _rootMapper.Map>(dtos);
+
public TEntity Map(TDto dto, TEntity entity) => _rootMapper.Map(dto, entity);
}
diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs
index 4686043..25c0185 100644
--- a/DigitalData.Core.Infrastructure/DbRepository.cs
+++ b/DigitalData.Core.Infrastructure/DbRepository.cs
@@ -33,11 +33,25 @@ public class DbRepository : IRepository where TDbC
return entities;
}
- public virtual async Task> ReadAsync(Expression>? expression = null, CancellationToken ct = default)
+ public virtual async Task> ReadAllAsync(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 ReadOrDefaultAsync(Expression> expression, bool single = true, CancellationToken ct = default)
+ => single
+ ? await Entities.AsNoTracking().Where(expression).SingleOrDefaultAsync(ct)
+ : await Entities.AsNoTracking().Where(expression).FirstOrDefaultAsync(ct);
+
+ public virtual async Task> ReadAllAsync(Expression>? expression = null, CancellationToken ct = default)
+ => Mapper.Map(await ReadAllAsync(expression, ct));
+
+ public virtual async Task ReadOrDefaultAsync(Expression> expression, bool single = true, CancellationToken ct = default)
+ {
+ var entity = await ReadOrDefaultAsync(expression, single, ct);
+ return entity is null ? default : Mapper.Map(entity);
+ }
+
public virtual async Task UpdateAsync(TDto dto, Expression> expression, CancellationToken ct = default)
{
var entities = await Entities.Where(expression).ToListAsync(ct);
diff --git a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
index c9638b6..1631ad7 100644
--- a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
+++ b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
@@ -6,7 +6,7 @@
enable
True
DigitalData.Core.Infrastructure
- 2.0.2
+ 2.0.3
Digital Data GmbH
Digital Data GmbH
DigitalData.Core.Infrastructure
@@ -16,8 +16,8 @@
http://git.dd:3000/AppStd/WebCoreModules.git
digital data core abstractions clean architecture
digital data core infrastructure clean architecture
- 2.0.2
- 2.0.2
+ 2.0.3
+ 2.0.3