using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using AutoMapper; using Microsoft.EntityFrameworkCore.Query; using xModels.Base; using xModels.Dtos; namespace xDataService.Interfaces { /// /// an Interface for Manipulating Data Using Services based on Dto Mapping ... /// /// /// /// public interface IXBaseRepositoryService : IDisposable where TEntity : XBaseEntity where TDto : XBaseEntityDto { // #region Properties ... /// /// Mapper Instance ... /// IMapper Mapper { get; } /// /// Repository Implementation for Data Manipulations ... /// IXBaseRepository Repository { get; } /// /// Mapping Profile Configuration ... /// /// this Configuration used for Mapping TEntity to Dto and reverse ... /// default mapping prepared on Constructing time, other custom maps /// must handled manually if required ... /// MapperConfiguration MapperConfiguration { get; } #endregion // #region Actions ... // #region Add ... /// /// add a new Dto ... /// /// /// /// /// Task AddAsync( TDto item, bool saveChanges = true, CancellationToken cancellationToken = default ); /// /// add or update a Dto (add if not exists/update if exists) ... /// /// /// /// /// Task AddOrUpdateAsync( TDto item, bool saveChanges = true, CancellationToken cancellationToken = default ); /// /// add a range of new Dtos ... /// /// /// /// /// Task AddRangeAsync( IEnumerable items, bool saveChanges = true, CancellationToken cancellationToken = default ); #endregion // #region Update ... /// /// Update an Dto values ... /// /// /// /// /// /// Task UpdateAsync( TKey id, TDto item, bool saveChanges = true, CancellationToken cancellationToken = default ); /// /// Update a range of Dtos ... /// /// /// /// /// Task UpdateRangeAsync( IEnumerable items, bool saveChanges = true, CancellationToken cancellationToken = default ); #endregion // #region Remove ... /// /// remove an Dto by it's Id ... /// /// /// /// /// /// Task RemoveAsync( TKey id, bool softDelete = true, bool saveChanges = true, CancellationToken cancellationToken = default ); /// /// remove an Dto ... /// /// /// /// /// /// Task RemoveAsync( TDto item, bool softDelete = true, bool saveChanges = true, CancellationToken cancellationToken = default ); /// /// remove a range of exists Dtos ... /// /// /// /// /// /// Task RemoveRangeAsync( IEnumerable items, bool softDelete = true, bool saveChanges = true, CancellationToken cancellationToken = default ); #endregion // #region Count ... /// /// count all exists Dtos ... /// /// /// /// Task CountAsync( bool ignoreSoftDeleteds = true, CancellationToken cancellationToken = default ); /// /// count all exists Entities Pages by providing page size ... /// /// /// /// /// /// Task PagesCountAsync( int pageSize, int? totalItems = null, bool ignoreSoftDeleteds = true, CancellationToken cancellationToken = default ); #endregion // #region Retrieve ... /// /// retrieve an Dto by it's Id ... /// /// /// /// /// /// Task GetAsync( TKey id, bool ignoreSoftDeleteds = true, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// retrieve all exists Dtos ... /// /// /// /// /// /// Task> GetAllAsync( bool ignoreSoftDeleteds = true, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// retrieve all exists Dtos /// as Async Enumerable ... /// /// /// /// /// /// IAsyncEnumerable GetAllAsAsyncEnumerable( bool ignoreSoftDeleteds = true, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// find an Dto by providing a Conditional Expression ... /// /// /// /// /// /// Task FindOneAsync( Expression> predicate, bool ignoreSoftDeleteds = true, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// find a collection of Dtos by proving a Conditional Expression ... /// /// /// /// /// /// /// Task> FindManyAsync( Expression> predicate, bool ignoreSoftDeleteds = true, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// retrieve Dtos based on XQuery Pagination structure ... /// /// /// /// /// /// /// /// Task> QueryAsync( XQuery query, bool ignoreSoftDeleteds = true, Expression> predicate = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); #endregion // #region Exists ... /// /// Check a Dto exists or not ... /// /// /// /// /// Task IsExistsAsync( TKey id, bool ignoreSoftDeleteds = true, CancellationToken cancellationToken = default ); #endregion #endregion } }