feat:Initial commit
This commit is contained in:
36
StoreService/Repositories/IGenericRepository.cs
Normal file
36
StoreService/Repositories/IGenericRepository.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace StoreService.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Generic repository abstraction for simple CRUD & query operations.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type.</typeparam>
|
||||
public interface IGenericRepository<TEntity> where TEntity : class
|
||||
{
|
||||
#region Query
|
||||
IQueryable<TEntity> Get(
|
||||
Expression<Func<TEntity, bool>>? filter = null,
|
||||
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>? orderBy = null,
|
||||
params Expression<Func<TEntity, object>>[] includes);
|
||||
|
||||
Task<TEntity?> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate,
|
||||
params Expression<Func<TEntity, object>>[] includes);
|
||||
|
||||
TEntity? GetById(object id);
|
||||
Task<TEntity?> GetByIdAsync(object id);
|
||||
#endregion
|
||||
|
||||
#region Mutations
|
||||
void Add(TEntity entity);
|
||||
Task AddAsync(TEntity entity);
|
||||
void AddRange(IEnumerable<TEntity> entities);
|
||||
|
||||
void Update(TEntity entity);
|
||||
|
||||
void Delete(object id);
|
||||
void Delete(TEntity entity);
|
||||
void DeleteRange(IEnumerable<TEntity> entities);
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user