using System.Linq.Expressions; using BuildingBlocks.Core.Model; namespace BuildingBlocks.Mongo; public interface IReadRepository where TEntity : class, IAggregate { Task FindByIdAsync(TId id, CancellationToken cancellationToken = default); Task FindOneAsync( Expression> predicate, CancellationToken cancellationToken = default); Task> FindAsync( Expression> predicate, CancellationToken cancellationToken = default); Task> GetAllAsync(CancellationToken cancellationToken = default); public Task> RawQuery( string query, CancellationToken cancellationToken = default, params object[] queryParams); } public interface IWriteRepository where TEntity : class, IAggregate { Task AddAsync(TEntity entity, CancellationToken cancellationToken = default); Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default); Task DeleteRangeAsync(IReadOnlyList entities, CancellationToken cancellationToken = default); Task DeleteAsync(Expression> predicate, CancellationToken cancellationToken = default); Task DeleteAsync(TEntity entity, CancellationToken cancellationToken = default); Task DeleteByIdAsync(TId id, CancellationToken cancellationToken = default); } public interface IRepository : IReadRepository, IWriteRepository, IDisposable where TEntity : class, IAggregate { } public interface IRepository : IRepository where TEntity : class, IAggregate { }