15c58522ef
- replace EfRepository/BaseDbContext/UtcValueConverter with BaseEfRepository and BaseRepository - add IEfRepository interface hierarchy - consolidate IEntity into Entity.cs, remove standalone IEntity.cs - add PagedResult - adjust all namespaces to HrynCo.DAL.Abstract / HrynCo.DAL.EF - add README.md with solution overview, versioning rules, class diagram - add AGENTS.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
namespace HrynCo.DAL.EF.Core;
|
|
|
|
using System.Linq.Expressions;
|
|
using HrynCo.DAL.Abstract.Entities;
|
|
|
|
public interface IEfRepository
|
|
{
|
|
void ClearChangeTracker();
|
|
}
|
|
|
|
public interface IEfRepository<TEntity, in TEntityId> : IEfRepository
|
|
where TEntity : IEntity<TEntityId> where TEntityId : struct
|
|
{
|
|
TEntity Add(TEntity entity, bool save = true);
|
|
void Add(TEntity[] entities, bool save = true);
|
|
Task<TEntity> AddAsync(TEntity entity, bool save = true);
|
|
|
|
void Delete(TEntity[] entities);
|
|
void Delete(TEntity entity);
|
|
void Delete(IEnumerable<TEntityId> id);
|
|
void Delete(TEntityId id);
|
|
|
|
Task DeleteAsync(TEntityId id);
|
|
Task DeleteAsync(IEnumerable<TEntityId> id);
|
|
Task DeleteAsync(TEntity entity);
|
|
|
|
IQueryable<TEntity> Get(
|
|
Expression<Func<TEntity, bool>>? filter = null,
|
|
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>? orderBy = null,
|
|
string includeProperties = "");
|
|
|
|
IQueryable<TEntity> GetAll();
|
|
|
|
void RemoveRange(IEnumerable<TEntity> entities);
|
|
void Remove(TEntity entity);
|
|
|
|
Task<List<TEntity>> GetAllAsync();
|
|
|
|
Task<bool> Exists(TEntityId id);
|
|
|
|
TEntity? GetById(TEntityId id);
|
|
Task<TEntity?> GetByIdAsync(TEntityId id);
|
|
Task UpdateAsync(TEntity entity, bool save = true);
|
|
|
|
void Update(TEntity entity, bool save = true);
|
|
|
|
Task SaveChangesAsync();
|
|
}
|
|
|
|
public interface IEfRepository<TEntity> : IEfRepository<TEntity, int>
|
|
where TEntity : IEntity<int>
|
|
{
|
|
}
|