Developer 02 6916e169b1 Add mapping methods to IRepository and DbRepository
Updated the `IRepository<TEntity>` interface to include two new mapping methods: `Map<TSource>(TSource source)` and `Map<TDto>(TEntity source)`.

Implemented these methods in the `DbRepository<TDbContext, TEntity>` class, utilizing a `Mapper` for conversions between source types and entity types, as well as between entity types and DTOs.
2025-04-17 13:01:51 +02:00

21 lines
806 B
C#

using System.Linq.Expressions;
namespace DigitalData.Core.Abstractions.Infrastructure;
public interface IRepository<TEntity>
{
public Task<TEntity> CreateAsync(TEntity entity, CancellationToken ct = default);
public Task<IEnumerable<TEntity>> CreateAsync(IEnumerable<TEntity> entities, CancellationToken ct = default);
public Task<IEnumerable<TEntity>> ReadAsync(Expression<Func<TEntity, bool>>? expression = null, CancellationToken ct = default);
public Task UpdateAsync<TUpdate>(TUpdate update, Expression<Func<TEntity, bool>> expression, CancellationToken ct = default);
public Task DeleteAsync<TDto>(Expression<Func<TEntity, bool>> expression, CancellationToken ct = default);
public TEntity Map<TSource>(TSource source);
public TDto Map<TDto>(TEntity source);
}