shopping-assistant-api/ShoppingAssistantApi.Application/IRepositories/IBaseRepository.cs
2023-10-14 19:53:47 +00:00

26 lines
1.1 KiB
C#

using MongoDB.Bson;
using ShoppingAssistantApi.Domain.Common;
using System.Linq.Expressions;
namespace ShoppingAssistantApi.Application.IRepositories;
public interface IBaseRepository<TEntity> where TEntity : EntityBase
{
Task<TEntity> AddAsync(TEntity entity, CancellationToken cancellationToken);
Task<TEntity> GetOneAsync(ObjectId id, CancellationToken cancellationToken);
Task<TEntity> GetOneAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken);
Task<List<TEntity>> GetPageAsync(int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<List<TEntity>> GetPageAsync(int pageNumber, int pageSize, Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken);
Task<bool> ExistsAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken);
Task<int> GetTotalCountAsync();
Task<int> GetCountAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken);
Task<TEntity> DeleteAsync(TEntity entity, CancellationToken cancellationToken);
}