- Updated `IRepository<TEntity>.Where()` to accept an `Expression<Func<TEntity, bool>>` for filtering. - Added `where TEntity : IEntity` constraint to `IRepository.Entity<TEntity>()` method. - No functional logic changes, only interface refactoring for stronger typing and query support.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using AutoMapper;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace DigitalData.Core.Abstraction.Application.Repository;
|
|
|
|
public interface IRepository<TEntity>
|
|
{
|
|
public IMapper Mapper { get; }
|
|
|
|
public Task<TEntity> CreateAsync(TEntity entity, CancellationToken cancel = default);
|
|
|
|
public Task<IEnumerable<TEntity>> CreateAsync(IEnumerable<TEntity> entities, CancellationToken cancel = default);
|
|
|
|
public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> expression);
|
|
|
|
public IQueryable<TEntity> Get();
|
|
|
|
public Task UpdateAsync<TDto>(TDto dto, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default);
|
|
|
|
public Task UpdateAsync<TDto>(TDto dto, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
|
|
|
|
public Task DeleteAsync(Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default);
|
|
|
|
public Task DeleteAsync(Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
|
|
|
|
#region Obsolete
|
|
[Obsolete("Use IRepository<TEntity>.Where")]
|
|
public IQueryable<TEntity> Read();
|
|
|
|
[Obsolete("Use IRepository<TEntity>.Get")]
|
|
public IQueryable<TEntity> ReadOnly();
|
|
#endregion
|
|
}
|
|
|
|
public interface IRepository
|
|
{
|
|
public IRepository<TEntity> Entity<TEntity>() where TEntity : IEntity;
|
|
} |