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.
21 lines
806 B
C#
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);
|
|
}
|