diff --git a/README.md b/README.md index 4187d26..4b4f6be 100644 --- a/README.md +++ b/README.md @@ -11,22 +11,27 @@ *** ## Give a Star 🌟 + If you liked the project or if **EasyRepository.EFCore** helped you, please give a star. *** ### Purpose + **Easy Repository For EF Core** provides implementation generic repository pattern on Entity Framework Core *** ## What is Generic Repository Pattern -The generic repository pattern implements in a separate class library project. ... The repository pattern is intended to create an Abstraction layer between the Data Access layer and Business Logic layer of an Application. It is a data access pattern that prompts a more loosely coupled approach to data access. +The generic repository pattern implements in a separate class library project. ... The repository pattern is intended to +create an Abstraction layer between the Data Access layer and Business Logic layer of an Application. It is a data +access pattern that prompts a more loosely coupled approach to data access. *** ### Documentation + Visit [Wiki](https://github.com/furkandeveloper/EasyRepository.EFCore/wiki) page for documentation. ## Star History diff --git a/common.props b/common.props index d6df6ff..eea7efa 100644 --- a/common.props +++ b/common.props @@ -1,21 +1,21 @@  - - Generic Repository Pattern For Entity Framework Core - Git - en-US - net6.0 - 2.0.0 - latest - false - https://github.com/furkandeveloper/EasyRepository.EFCore - furkandeveloper - true - true - - dotnet, efcore, repository-pattern, generic-repository, generic-repository-pattern - - - - MIT - + + Generic Repository Pattern For Entity Framework Core + Git + en-US + net6.0 + 2.0.1 + latest + false + https://github.com/furkandeveloper/EasyRepository.EFCore + furkandeveloper + true + true + + dotnet, efcore, repository-pattern, generic-repository, generic-repository-pattern + + Added Enum.AsNoTracking overloads for all methods which use asNoTracking (boolean) + + MIT + diff --git a/sample/EasyRepository.Sample/Context/SampleDbContext.cs b/sample/EasyRepository.Sample/Context/SampleDbContext.cs index 9154f1d..48123b3 100644 --- a/sample/EasyRepository.Sample/Context/SampleDbContext.cs +++ b/sample/EasyRepository.Sample/Context/SampleDbContext.cs @@ -1,62 +1,59 @@ -using EasyRepository.Sample.Entities; +namespace EasyRepository.Sample.Context; + +using Entities; using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -namespace EasyRepository.Sample.Context +/// +/// Sample Database Context +/// +public class SampleDbContext : DbContext { /// - /// Sample Database Context + /// Ctor /// - public class SampleDbContext : DbContext + /// + /// The options to be used by a Microsoft.EntityFrameworkCore.DbContext. You normally + /// override + /// Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder) + /// or use a Microsoft.EntityFrameworkCore.DbContextOptionsBuilder to create instances + /// of this class and it is not designed to be directly constructed in your application + /// code. + /// + public SampleDbContext(DbContextOptions options) + : base(options) + { + } + + protected SampleDbContext() { - /// - /// Ctor - /// - /// - /// The options to be used by a Microsoft.EntityFrameworkCore.DbContext. You normally - /// override Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder) - /// or use a Microsoft.EntityFrameworkCore.DbContextOptionsBuilder to create instances - /// of this class and it is not designed to be directly constructed in your application - /// code. - /// - public SampleDbContext(DbContextOptions options) : base(options) - { - } - - protected SampleDbContext() - { - } - - public virtual DbSet Authors { get; set;} - - public virtual DbSet Books { get; set; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - modelBuilder.Entity(entity => + } + + public virtual DbSet Authors { get; set; } + + public virtual DbSet Books { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + modelBuilder.Entity( + entity => { - entity - .HasMany(m => m.Books) + entity.HasMany(m => m.Books) .WithOne(o => o.Author) .HasForeignKey(fk => fk.AuthorId); }); - modelBuilder.Entity(entity => + modelBuilder.Entity( + entity => { - entity - .HasOne(o => o.Author) + entity.HasOne(o => o.Author) .WithMany(m => m.Books) .HasForeignKey(fk => fk.AuthorId); }); - } + } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - base.OnConfiguring(optionsBuilder); - } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + base.OnConfiguring(optionsBuilder); } -} +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Controllers/AuthorController.cs b/sample/EasyRepository.Sample/Controllers/AuthorController.cs index 993a221..ab8f0e6 100644 --- a/sample/EasyRepository.Sample/Controllers/AuthorController.cs +++ b/sample/EasyRepository.Sample/Controllers/AuthorController.cs @@ -1,144 +1,167 @@ -using EasyRepository.EFCore.Abstractions; -using EasyRepository.Sample.Dtos.Request; -using EasyRepository.Sample.Entities; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Query; +namespace EasyRepository.Sample.Controllers; + using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using EasyRepository.EFCore.Ardalis.Specification; -using EasyRepository.EFCore.Generic; -using EasyRepository.Sample.Specs; +using Dtos.Request; +using EFCore.Abstractions; +using EFCore.Ardalis.Specification; +using EFCore.Generic; +using Entities; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; +using Specs; -namespace EasyRepository.Sample.Controllers +[ApiController] +[Route("[controller]")] +public class AuthorController : ControllerBase { - [ApiController] - [Route("[controller]")] - public class AuthorController : ControllerBase + private readonly IUnitOfWork _unitOfWork; + + public AuthorController(IRepository repository, IUnitOfWork unitOfWork) + { + this._unitOfWork = unitOfWork; + } + + [HttpPost] + public async Task AddAuthorAsync([FromBody] AuthorRequestDto dto) { - private readonly IUnitOfWork _unitOfWork; - - public AuthorController(IRepository repository, IUnitOfWork unitOfWork) - { - _unitOfWork = unitOfWork; - } - - [HttpGet(Name = "FilterAuthor")] - public async Task FilterAuthorAsync([FromQuery]string name) - { - var queryable = _unitOfWork.Repository.GetQueryable(); - //var spec = new AuthorByNameSpec(name); - var spec = new AuthorOrderByNameSpec(name); - var data = SpecificationConverter.Convert(queryable, spec); - return Ok(data.ToList()); - } - - [HttpPost] - public async Task AddAuthorAsync([FromBody] AuthorRequestDto dto) - { - var entity = await _unitOfWork.Repository.AddAsync(new Author + var entity = await this._unitOfWork.Repository.AddAsync( + new Author { Name = dto.Name, Surname = dto.Surname }); - var book = await _unitOfWork.Repository.AddAsync(new Book - { - Title = "Book 123", - TotalPage = 124, - AuthorId = entity.Id - }); - - await _unitOfWork.Repository.CompleteAsync(); - return Ok(entity); - } - - [HttpPost("range")] - public async Task AddAuthorAsync([FromBody] List dto) - { - var entity = await _unitOfWork.Repository.AddRangeAsync(dto.Select(s => new Author + var book = await this._unitOfWork.Repository.AddAsync( + new Book { - Name = s.Name, - Surname = s.Surname - }).ToList(), default); - - return Ok(entity); - } - - [HttpPut("{id}")] - public async Task UpdateAuthorAsync([FromRoute] Guid id, [FromBody] AuthorRequestDto dto) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - entity.Name = dto.Name; - entity.Surname = dto.Surname; - var result = await _unitOfWork.Repository.UpdateAsync(entity); - return Ok(result); - } - - [HttpDelete("{id}/hard")] - public async Task HardDeleteAsync([FromRoute] Guid id) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - await _unitOfWork.Repository.HardDeleteAsync(entity); - return NoContent(); - } - - [HttpDelete("{id}/soft")] - public async Task SoftDeleteAsync([FromRoute] Guid id) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - await _unitOfWork.Repository.SoftDeleteAsync(entity); - return NoContent(); - } - - [HttpGet("{id}")] - public async Task GetByIdAsync([FromRoute] Guid id) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - return Ok(entity); - } - - [HttpGet("multiple")] - public async Task GetMultipleAsync() - { - var entities = await _unitOfWork.Repository.GetMultipleAsync(false); - return Ok(entities); - } - - [HttpGet("selectable-multiple")] - public async Task GetSelectableMultipleAsync() - { - var entities = await _unitOfWork.Repository.GetMultipleAsync(false, select => new + Title = "Book 123", + TotalPage = 124, + AuthorId = entity.Id + }); + + await this._unitOfWork.Repository.CompleteAsync(); + + return this.Ok(entity); + } + + [HttpPost("range")] + public async Task AddAuthorAsync([FromBody] List dto) + { + var entity = await this._unitOfWork.Repository.AddRangeAsync( + dto.Select( + s => new Author + { + Name = s.Name, + Surname = s.Surname + }) + .ToList()); + + return this.Ok(entity); + } + + [HttpGet(Name = "FilterAuthor")] + public async Task FilterAuthorAsync([FromQuery] string name) + { + var queryable = this._unitOfWork.Repository.GetQueryable(); + //var spec = new AuthorByNameSpec(name); + var spec = new AuthorOrderByNameSpec(name); + var data = SpecificationConverter.Convert(queryable, spec); + + return this.Ok(data.ToList()); + } + + [HttpGet("{id}")] + public async Task GetByIdAsync([FromRoute] Guid id) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + + return this.Ok(entity); + } + + [HttpGet("filterable-multiple")] + public async Task GetFilterableMultipleAsync([FromQuery] AuthorFilterDto dto) + { + var entities = await this._unitOfWork.Repository.GetMultipleAsync( + false, + dto, + select => new { SelectName = select.Name, SelectDate = select.CreationDate }); - return Ok(entities); - } - [HttpGet("filterable-multiple")] - public async Task GetFilterableMultipleAsync([FromQuery] AuthorFilterDto dto) - { - var entities = await _unitOfWork.Repository.GetMultipleAsync(false, dto, select => new + return this.Ok(entities); + } + + [HttpGet("includable-filterable-selectable-multiple")] + public async Task GetIncludeableFilterableMultipleAsync([FromQuery] AuthorFilterDto dto) + { + Func, IIncludableQueryable> include = a => a.Include(i => i.Books); + var entities = await this._unitOfWork.Repository.GetMultipleAsync( + false, + dto, + select => new { SelectName = select.Name, SelectDate = select.CreationDate - }); - return Ok(entities); - } - - [HttpGet("includable-filterable-selectable-multiple")] - public async Task GetIncludeableFilterableMultipleAsync([FromQuery] AuthorFilterDto dto) - { - Func, IIncludableQueryable> include = a => a.Include(i => i.Books); - var entities = await _unitOfWork.Repository.GetMultipleAsync(false, dto, select => new + }, + include); + + return this.Ok(entities); + } + + [HttpGet("multiple")] + public async Task GetMultipleAsync() + { + var entities = await this._unitOfWork.Repository.GetMultipleAsync(false); + + return this.Ok(entities); + } + + [HttpGet("selectable-multiple")] + public async Task GetSelectableMultipleAsync() + { + var entities = await this._unitOfWork.Repository.GetMultipleAsync( + false, + select => new { SelectName = select.Name, SelectDate = select.CreationDate - }, include); - return Ok(entities); - } + }); + + return this.Ok(entities); + } + + [HttpDelete("{id}/hard")] + public async Task HardDeleteAsync([FromRoute] Guid id) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + await this._unitOfWork.Repository.HardDeleteAsync(entity); + + return this.NoContent(); + } + + [HttpDelete("{id}/soft")] + public async Task SoftDeleteAsync([FromRoute] Guid id) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + await this._unitOfWork.Repository.SoftDeleteAsync(entity); + + return this.NoContent(); + } + + [HttpPut("{id}")] + public async Task UpdateAuthorAsync([FromRoute] Guid id, [FromBody] AuthorRequestDto dto) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + entity.Name = dto.Name; + entity.Surname = dto.Surname; + var result = await this._unitOfWork.Repository.UpdateAsync(entity); + + return this.Ok(result); } -} +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Controllers/BookController.cs b/sample/EasyRepository.Sample/Controllers/BookController.cs index 956f926..bb13405 100644 --- a/sample/EasyRepository.Sample/Controllers/BookController.cs +++ b/sample/EasyRepository.Sample/Controllers/BookController.cs @@ -1,134 +1,154 @@ -using EasyRepository.EFCore.Abstractions; -using EasyRepository.Sample.Dtos.Request; -using EasyRepository.Sample.Entities; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Query; +namespace EasyRepository.Sample.Controllers; + using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using EasyRepository.EFCore.Generic; +using Dtos.Request; +using EFCore.Generic; +using Entities; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; -namespace EasyRepository.Sample.Controllers +[ApiController] +[Route("[controller]")] +public class BookController : ControllerBase { - [ApiController] - [Route("[controller]")] - public class BookController : ControllerBase - { - private readonly IUnitOfWork _unitOfWork; + private readonly IUnitOfWork _unitOfWork; - public BookController(IUnitOfWork unitOfWork) - { - _unitOfWork = unitOfWork; - } + public BookController(IUnitOfWork unitOfWork) + { + this._unitOfWork = unitOfWork; + } - [HttpPost("authors/{authorId}")] - public async Task AddBookAsync([FromRoute] Guid authorId,[FromBody] BookRequestDto dto) - { - var entity = await _unitOfWork.Repository.AddAsync(new Book + [HttpPost("authors/{authorId}")] + public async Task AddBookAsync([FromRoute] Guid authorId, [FromBody] BookRequestDto dto) + { + var entity = await this._unitOfWork.Repository.AddAsync( + new Book { Title = dto.Title, TotalPage = dto.TotalPage, AuthorId = authorId - }, default); + }); - await _unitOfWork.Repository.CompleteAsync(); + await this._unitOfWork.Repository.CompleteAsync(); - return Ok(entity); - } + return this.Ok(entity); + } - [HttpPost("authors/{authorId}/range")] - public async Task AddBookAsync([FromRoute] Guid authorId, [FromBody] List dto) - { - var entity = await _unitOfWork.Repository.AddRangeAsync(dto.Select(s => new Book - { - Title = s.Title, - TotalPage = s.TotalPage, - AuthorId = authorId - }).ToList(), default); - - await _unitOfWork.Repository.CompleteAsync(); - return Ok(entity); - } - - [HttpPut("{id}/authors/{authorId}")] - public async Task UpdateAuthorAsync([FromRoute] Guid id,[FromRoute] Guid authorId, [FromBody] BookRequestDto dto) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - entity.Title = dto.Title; - entity.TotalPage = dto.TotalPage; - entity.AuthorId = authorId; - var result = await _unitOfWork.Repository.UpdateAsync(entity); - await _unitOfWork.Repository.CompleteAsync(); - return Ok(result); - } - - [HttpDelete("{id}/hard")] - public async Task HardDeleteAsync([FromRoute] Guid id) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - await _unitOfWork.Repository.HardDeleteAsync(entity); - await _unitOfWork.Repository.CompleteAsync(); - return NoContent(); - } - - [HttpDelete("{id}/soft")] - public async Task SoftDeleteAsync([FromRoute] Guid id) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - await _unitOfWork.Repository.SoftDeleteAsync(entity); - await _unitOfWork.Repository.CompleteAsync(); - return NoContent(); - } - - [HttpGet("{id}")] - public async Task GetByIdAsync([FromRoute] Guid id) - { - var entity = await _unitOfWork.Repository.GetByIdAsync(true, id); - return Ok(entity); - } - - [HttpGet("multiple")] - public async Task GetMultipleAsync() - { - var entities = await _unitOfWork.Repository.GetMultipleAsync(false); - return Ok(entities); - } - - [HttpGet("selectable-multiple")] - public async Task GetSelectableMultipleAsync() - { - var entities = await _unitOfWork.Repository.GetMultipleAsync(false, select => new - { - SelectTitle = select.Title, - SelectTotalPage = select.TotalPage - }); - return Ok(entities); - } + [HttpPost("authors/{authorId}/range")] + public async Task AddBookAsync([FromRoute] Guid authorId, [FromBody] List dto) + { + var entity = await this._unitOfWork.Repository.AddRangeAsync( + dto.Select( + s => new Book + { + Title = s.Title, + TotalPage = s.TotalPage, + AuthorId = authorId + }) + .ToList()); + + await this._unitOfWork.Repository.CompleteAsync(); + + return this.Ok(entity); + } + + [HttpGet("{id}")] + public async Task GetByIdAsync([FromRoute] Guid id) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); - [HttpGet("filterable-multiple")] - public async Task GetFilterableMultipleAsync([FromQuery] BookFilterDto dto) - { - var entities = await _unitOfWork.Repository.GetMultipleAsync(false, dto, select => new + return this.Ok(entity); + } + + [HttpGet("filterable-multiple")] + public async Task GetFilterableMultipleAsync([FromQuery] BookFilterDto dto) + { + var entities = await this._unitOfWork.Repository.GetMultipleAsync( + false, + dto, + select => new { SelectTitle = select.Title, SelectTotalPage = select.TotalPage }); - return Ok(entities); - } - - [HttpGet("includable-filterable-selectable-multiple")] - public async Task GetIncludeableFilterableMultipleAsync([FromQuery] BookFilterDto dto) - { - Func, IIncludableQueryable> include = a => a.Include(i => i.Author); - var entities = await _unitOfWork.Repository.GetMultipleAsync(false, dto, select => new + + return this.Ok(entities); + } + + [HttpGet("includable-filterable-selectable-multiple")] + public async Task GetIncludeableFilterableMultipleAsync([FromQuery] BookFilterDto dto) + { + Func, IIncludableQueryable> include = a => a.Include(i => i.Author); + var entities = await this._unitOfWork.Repository.GetMultipleAsync( + false, + dto, + select => new { SelectName = select.Title, SelectDate = select.CreationDate, Author = select.Author.Name - }, include); - return Ok(entities); - } + }, + include); + + return this.Ok(entities); + } + + [HttpGet("multiple")] + public async Task GetMultipleAsync() + { + var entities = await this._unitOfWork.Repository.GetMultipleAsync(false); + + return this.Ok(entities); + } + + [HttpGet("selectable-multiple")] + public async Task GetSelectableMultipleAsync() + { + var entities = await this._unitOfWork.Repository.GetMultipleAsync( + false, + select => new + { + SelectTitle = select.Title, + SelectTotalPage = select.TotalPage + }); + + return this.Ok(entities); + } + + [HttpDelete("{id}/hard")] + public async Task HardDeleteAsync([FromRoute] Guid id) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + await this._unitOfWork.Repository.HardDeleteAsync(entity); + await this._unitOfWork.Repository.CompleteAsync(); + + return this.NoContent(); + } + + [HttpDelete("{id}/soft")] + public async Task SoftDeleteAsync([FromRoute] Guid id) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + await this._unitOfWork.Repository.SoftDeleteAsync(entity); + await this._unitOfWork.Repository.CompleteAsync(); + + return this.NoContent(); + } + + [HttpPut("{id}/authors/{authorId}")] + public async Task UpdateAuthorAsync([FromRoute] Guid id, [FromRoute] Guid authorId, [FromBody] BookRequestDto dto) + { + var entity = await this._unitOfWork.Repository.GetByIdAsync(true, id); + entity.Title = dto.Title; + entity.TotalPage = dto.TotalPage; + entity.AuthorId = authorId; + var result = await this._unitOfWork.Repository.UpdateAsync(entity); + await this._unitOfWork.Repository.CompleteAsync(); + + return this.Ok(result); } -} +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Dtos/Request/AuthorFilterDto.cs b/sample/EasyRepository.Sample/Dtos/Request/AuthorFilterDto.cs index 8e44b18..721c611 100644 --- a/sample/EasyRepository.Sample/Dtos/Request/AuthorFilterDto.cs +++ b/sample/EasyRepository.Sample/Dtos/Request/AuthorFilterDto.cs @@ -1,30 +1,27 @@ -using AutoFilterer.Attributes; -using AutoFilterer.Types; +namespace EasyRepository.Sample.Dtos.Request; + using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using AutoFilterer.Attributes; +using AutoFilterer.Enums; +using AutoFilterer.Types; -namespace EasyRepository.Sample.Dtos.Request +[PossibleSortings("Name", "Surname", "CreationDate", "ModificationDate", "DeletionDate")] +public class AuthorFilterDto : PaginationFilterBase { - [PossibleSortings("Name", "Surname","CreationDate", "ModificationDate", "DeletionDate")] - public class AuthorFilterDto : PaginationFilterBase + public AuthorFilterDto() { - public AuthorFilterDto() - { - this.Sort = "Name"; - this.SortBy = AutoFilterer.Enums.Sorting.Descending; - } + this.Sort = "Name"; + this.SortBy = Sorting.Descending; + } - [ToLowerContainsComparison] - public string Name { get; set; } + [ToLowerContainsComparison] + public string Name { get; set; } - [ToLowerContainsComparison] - public string Surname { get; set; } + [ToLowerContainsComparison] + public string Surname { get; set; } - public Range CreationDate { get; set; } + public Range CreationDate { get; set; } - public Range ModificationDate { get; set; } - public Range DeletionDate { get; set; } - } -} + public Range ModificationDate { get; set; } + public Range DeletionDate { get; set; } +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Dtos/Request/AuthorRequestDto.cs b/sample/EasyRepository.Sample/Dtos/Request/AuthorRequestDto.cs index 6f34035..66a8179 100644 --- a/sample/EasyRepository.Sample/Dtos/Request/AuthorRequestDto.cs +++ b/sample/EasyRepository.Sample/Dtos/Request/AuthorRequestDto.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +namespace EasyRepository.Sample.Dtos.Request; -namespace EasyRepository.Sample.Dtos.Request +public class AuthorRequestDto { - public class AuthorRequestDto - { - public string Name { get; set; } + public string Name { get; set; } - public string Surname { get; set; } - } -} + public string Surname { get; set; } +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Dtos/Request/BookFilterDto.cs b/sample/EasyRepository.Sample/Dtos/Request/BookFilterDto.cs index 746a9b2..0e8d6c7 100644 --- a/sample/EasyRepository.Sample/Dtos/Request/BookFilterDto.cs +++ b/sample/EasyRepository.Sample/Dtos/Request/BookFilterDto.cs @@ -1,29 +1,26 @@ -using AutoFilterer.Attributes; -using AutoFilterer.Types; +namespace EasyRepository.Sample.Dtos.Request; + using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using AutoFilterer.Attributes; +using AutoFilterer.Enums; +using AutoFilterer.Types; -namespace EasyRepository.Sample.Dtos.Request +[PossibleSortings("Title", "CreationDate", "ModificationDate", "DeletionDate")] +public class BookFilterDto : PaginationFilterBase { - [PossibleSortings("Title", "CreationDate", "ModificationDate", "DeletionDate")] - public class BookFilterDto : PaginationFilterBase + public BookFilterDto() { - public BookFilterDto() - { - this.Sort = "Title"; - this.SortBy = AutoFilterer.Enums.Sorting.Descending; - } + this.Sort = "Title"; + this.SortBy = Sorting.Descending; + } - [ToLowerContainsComparison] - public string Title { get; set; } + [ToLowerContainsComparison] + public string Title { get; set; } - public Range TotalPage { get; set; } + public Range TotalPage { get; set; } - public Range CreationDate { get; set; } + public Range CreationDate { get; set; } - public Range ModificationDate { get; set; } - public Range DeletionDate { get; set; } - } -} + public Range ModificationDate { get; set; } + public Range DeletionDate { get; set; } +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Dtos/Request/BookRequestDto.cs b/sample/EasyRepository.Sample/Dtos/Request/BookRequestDto.cs index 10bf2d5..3b48139 100644 --- a/sample/EasyRepository.Sample/Dtos/Request/BookRequestDto.cs +++ b/sample/EasyRepository.Sample/Dtos/Request/BookRequestDto.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +namespace EasyRepository.Sample.Dtos.Request; -namespace EasyRepository.Sample.Dtos.Request +public class BookRequestDto { - public class BookRequestDto - { - public string Title { get; set; } + public string Title { get; set; } - public int TotalPage { get; set; } - } -} + public int TotalPage { get; set; } +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/EasyRepository.Sample.csproj b/sample/EasyRepository.Sample/EasyRepository.Sample.csproj index b296e47..574c54b 100644 --- a/sample/EasyRepository.Sample/EasyRepository.Sample.csproj +++ b/sample/EasyRepository.Sample/EasyRepository.Sample.csproj @@ -1,25 +1,25 @@  - - net6.0 - - - bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + net6.0 + + + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - - + + + + diff --git a/sample/EasyRepository.Sample/Entities/Author.cs b/sample/EasyRepository.Sample/Entities/Author.cs index 943e5da..847c01d 100644 --- a/sample/EasyRepository.Sample/Entities/Author.cs +++ b/sample/EasyRepository.Sample/Entities/Author.cs @@ -1,19 +1,16 @@ -using EasyRepository.EFCore.Abstractions; +namespace EasyRepository.Sample.Entities; + using System; using System.Collections.Generic; -using System.Linq; using System.Text.Json.Serialization; -using System.Threading.Tasks; +using EFCore.Abstractions; -namespace EasyRepository.Sample.Entities +public class Author : EasyBaseEntity { - public class Author : EasyBaseEntity - { - public string Name { get; set; } + public string Name { get; set; } - public string Surname { get; set; } + public string Surname { get; set; } - [JsonIgnore] - public virtual ICollection Books { get; set; } - } -} + [JsonIgnore] + public virtual ICollection Books { get; set; } +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Entities/Book.cs b/sample/EasyRepository.Sample/Entities/Book.cs index 3de8b61..6f23ec4 100644 --- a/sample/EasyRepository.Sample/Entities/Book.cs +++ b/sample/EasyRepository.Sample/Entities/Book.cs @@ -1,19 +1,14 @@ -using EasyRepository.EFCore.Abstractions; +namespace EasyRepository.Sample.Entities; + using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using EFCore.Abstractions; -namespace EasyRepository.Sample.Entities +public class Book : EasyBaseEntity { - public class Book : EasyBaseEntity - { - public string Title { get; set; } - - public Guid AuthorId { get; set; } + public Guid AuthorId { get; set; } + public string Title { get; set; } - public int TotalPage { get; set; } + public int TotalPage { get; set; } - public virtual Author Author { get; set; } - } -} + public virtual Author Author { get; set; } +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Program.cs b/sample/EasyRepository.Sample/Program.cs index 0f353d9..ff4164b 100644 --- a/sample/EasyRepository.Sample/Program.cs +++ b/sample/EasyRepository.Sample/Program.cs @@ -1,26 +1,20 @@ +namespace EasyRepository.Sample; + using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -namespace EasyRepository.Sample +public class Program { - public class Program + public static IHostBuilder CreateHostBuilder(string[] args) { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } + return Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); + } - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); + public static void Main(string[] args) + { + CreateHostBuilder(args) + .Build() + .Run(); } -} +} \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Specs/AuthorByNameSpec.cs b/sample/EasyRepository.Sample/Specs/AuthorByNameSpec.cs index 3d0658d..bc89f30 100644 --- a/sample/EasyRepository.Sample/Specs/AuthorByNameSpec.cs +++ b/sample/EasyRepository.Sample/Specs/AuthorByNameSpec.cs @@ -1,17 +1,16 @@ -using Ardalis.Specification; -using EasyRepository.Sample.Entities; +namespace EasyRepository.Sample.Specs; -namespace EasyRepository.Sample.Specs +using Ardalis.Specification; +using Entities; + +/// +/// Author By Name specification +/// +public sealed class AuthorByNameSpec : Specification { - /// - /// Author By Name specification - /// - public sealed class AuthorByNameSpec : Specification + /// + public AuthorByNameSpec(string name) { - /// - public AuthorByNameSpec(string name) - { - Query.Where(c => c.Name == name); - } + this.Query.Where(c => c.Name == name); } } \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Specs/AuthorOrderByNameSpec.cs b/sample/EasyRepository.Sample/Specs/AuthorOrderByNameSpec.cs index 607e3d3..037395f 100644 --- a/sample/EasyRepository.Sample/Specs/AuthorOrderByNameSpec.cs +++ b/sample/EasyRepository.Sample/Specs/AuthorOrderByNameSpec.cs @@ -1,36 +1,35 @@ -using Ardalis.Specification; -using EasyRepository.Sample.Entities; +namespace EasyRepository.Sample.Specs; -namespace EasyRepository.Sample.Specs +using Ardalis.Specification; +using Entities; + +/// +/// Order by author name specification +/// +public sealed class AuthorOrderByNameSpec : Specification { - /// - /// Order by author name specification - /// - public sealed class AuthorOrderByNameSpec : Specification + /// + public AuthorOrderByNameSpec(string name) { - /// - public AuthorOrderByNameSpec(string name) - { - Query.ApplyBaseRules().ApplyByName(name).OrderBy(o => o.Name); - } + this.Query.ApplyBaseRules() + .ApplyByName(name) + .OrderBy(o => o.Name); } +} - public static class AuthorSpecification +public static class AuthorSpecification +{ + public static ISpecificationBuilder ApplyBaseRules(this ISpecificationBuilder specificationBuilder) { - public static ISpecificationBuilder ApplyBaseRules( - this ISpecificationBuilder specificationBuilder) - { - specificationBuilder.Include(x => x.Books); + specificationBuilder.Include(x => x.Books); - return specificationBuilder; - } - - public static ISpecificationBuilder ApplyByName( - this ISpecificationBuilder specificationBuilder, string name) - { - specificationBuilder.Where(a => a.Name.Contains(name)); + return specificationBuilder; + } + + public static ISpecificationBuilder ApplyByName(this ISpecificationBuilder specificationBuilder, string name) + { + specificationBuilder.Where(a => a.Name.Contains(name)); - return specificationBuilder; - } + return specificationBuilder; } } \ No newline at end of file diff --git a/sample/EasyRepository.Sample/Startup.cs b/sample/EasyRepository.Sample/Startup.cs index 230677f..3e4a436 100644 --- a/sample/EasyRepository.Sample/Startup.cs +++ b/sample/EasyRepository.Sample/Startup.cs @@ -1,6 +1,11 @@ +namespace EasyRepository.Sample; + +using System; +using System.IO; +using System.Reflection; using AutoFilterer.Swagger; -using EasyRepository.EFCore.Generic; -using EasyRepository.Sample.Context; +using Context; +using EFCore.Generic; using MarkdownDocumenting.Extensions; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -8,84 +13,80 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using System; -using System.IO; -using System.Reflection; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerUI; -namespace EasyRepository.Sample +public class Startup { - public class Startup + public Startup(IConfiguration configuration) { - public IConfiguration Configuration { get; } + this.Configuration = configuration; + } + + public IConfiguration Configuration { get; } - public Startup(IConfiguration configuration) + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) { - Configuration = configuration; + app.UseDeveloperExceptionPage(); } - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - services.AddControllersWithViews(); - services.AddDbContext(options => + app.UseRouting(); + app.UseSwagger(); + + app.UseSwaggerUI( + options => { - options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")); - }, ServiceLifetime.Transient); - - services.ApplyEasyRepository(); + options.EnableDeepLinking(); + options.ShowExtensions(); + options.DisplayRequestDuration(); + options.DocExpansion(DocExpansion.None); + options.RoutePrefix = "api-docs"; + options.SwaggerEndpoint("/swagger/EasyRepository/swagger.json", "EasyProfilerSwagger"); + }); + app.UseDocumentation(opts => this.Configuration.Bind("DocumentationOptions", opts)); + app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); + } + + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + services.AddControllersWithViews(); - services.AddSwaggerGen(options => + services.AddDbContext(options => { options.UseNpgsql(this.Configuration.GetConnectionString("DefaultConnection")); }, ServiceLifetime.Transient); + + services.ApplyEasyRepository(); + + services.AddSwaggerGen( + options => { - options.SwaggerDoc("EasyRepository", new Microsoft.OpenApi.Models.OpenApiInfo() - { - Title = "Easy Repository", - Version = "1.0.0", - Description = "This repo, provides implement generic repository pattern on ef core", - Contact = new Microsoft.OpenApi.Models.OpenApiContact() + options.SwaggerDoc( + "EasyRepository", + new OpenApiInfo { - Email = "furkan.dvlp@gmail.com", - Url = new Uri("https://github.com/furkandeveloper/EasyRepository.EFCore") - } - }); + Title = "Easy Repository", + Version = "1.0.0", + Description = "This repo, provides implement generic repository pattern on ef core", + Contact = new OpenApiContact + { + Email = "furkan.dvlp@gmail.com", + Url = new Uri("https://github.com/furkandeveloper/EasyRepository.EFCore") + } + }); options.UseAutoFiltererParameters(); var docFile = $"{Assembly.GetEntryAssembly().GetName().Name}.xml"; var filePath = Path.Combine(AppContext.BaseDirectory, docFile); - if (File.Exists((filePath))) + if (File.Exists(filePath)) { options.IncludeXmlComments(filePath); } - options.DescribeAllParametersInCamelCase(); - }); - services.AddDocumentation(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseRouting(); - app.UseSwagger(); - app.UseSwaggerUI(options => - { - options.EnableDeepLinking(); - options.ShowExtensions(); - options.DisplayRequestDuration(); - options.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None); - options.RoutePrefix = "api-docs"; - options.SwaggerEndpoint("/swagger/EasyRepository/swagger.json", "EasyProfilerSwagger"); - }); - app.UseDocumentation(opts => this.Configuration.Bind("DocumentationOptions", opts)); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); + options.DescribeAllParametersInCamelCase(); }); - } + services.AddDocumentation(); } -} +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/EasyBaseEntity.cs b/src/EasyRepository.EFCore.Abstractions/EasyBaseEntity.cs index 23f3c53..6b5164c 100644 --- a/src/EasyRepository.EFCore.Abstractions/EasyBaseEntity.cs +++ b/src/EasyRepository.EFCore.Abstractions/EasyBaseEntity.cs @@ -1,38 +1,37 @@ -using System; +namespace EasyRepository.EFCore.Abstractions; -namespace EasyRepository.EFCore.Abstractions +using System; + +/// +/// This abstraction implemented base properties for entities +/// +/// +/// Primary Key type of the entity +/// +public abstract class EasyBaseEntity : IEasyEntity, IEasyCreateDateEntity, IEasyUpdateDateEntity, IEasySoftDeleteEntity { /// - /// This abstraction implemented base properties for entities + /// Creation Date /// - /// - /// Primary Key type of the entity - /// - public abstract class EasyBaseEntity : IEasyEntity, IEasyCreateDateEntity, IEasyUpdateDateEntity, IEasySoftDeleteEntity - { - /// - /// Creation Date - /// - public virtual DateTime CreationDate { get; set; } + public virtual DateTime CreationDate { get; set; } - /// - /// Primary Key - /// - public virtual TPrimaryKey Id { get; set; } + /// + /// Primary Key + /// + public virtual TPrimaryKey Id { get; set; } - /// - /// Modification Date - /// - public virtual DateTime? ModificationDate { get; set; } + /// + /// Deletion Date + /// + public virtual DateTime? DeletionDate { get; set; } - /// - /// Deletion Date - /// - public virtual DateTime? DeletionDate { get; set; } + /// + /// Is Deleted + /// + public virtual bool IsDeleted { get; set; } - /// - /// Is Deleted - /// - public virtual bool IsDeleted { get; set; } - } -} + /// + /// Modification Date + /// + public virtual DateTime? ModificationDate { get; set; } +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/EasyRepository.EFCore.Abstractions.csproj b/src/EasyRepository.EFCore.Abstractions/EasyRepository.EFCore.Abstractions.csproj index d71b993..9d6dc78 100644 --- a/src/EasyRepository.EFCore.Abstractions/EasyRepository.EFCore.Abstractions.csproj +++ b/src/EasyRepository.EFCore.Abstractions/EasyRepository.EFCore.Abstractions.csproj @@ -1,20 +1,20 @@  - + - - folders.png - - - - - - - - - True - - - + + folders.png + + + + + + + + + True + + + diff --git a/src/EasyRepository.EFCore.Abstractions/Enums/EfTrackingOptions.cs b/src/EasyRepository.EFCore.Abstractions/Enums/EfTrackingOptions.cs new file mode 100644 index 0000000..80c21d2 --- /dev/null +++ b/src/EasyRepository.EFCore.Abstractions/Enums/EfTrackingOptions.cs @@ -0,0 +1,14 @@ +namespace EasyRepository.EFCore.Abstractions.Enums; + +public enum EfTrackingOptions +{ + /// + /// Disables EfCore change tracking + /// + AsNoTracking, + + /// + /// Enables EfCore Change Tracking + /// + WithTracking +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/IEasyCreateDateEntity.cs b/src/EasyRepository.EFCore.Abstractions/IEasyCreateDateEntity.cs index 76bb3ec..c81e5e2 100644 --- a/src/EasyRepository.EFCore.Abstractions/IEasyCreateDateEntity.cs +++ b/src/EasyRepository.EFCore.Abstractions/IEasyCreateDateEntity.cs @@ -1,15 +1,14 @@ -using System; +namespace EasyRepository.EFCore.Abstractions; -namespace EasyRepository.EFCore.Abstractions +using System; + +/// +/// This interface implemented creation date for entity +/// +public interface IEasyCreateDateEntity { /// - /// This interface implemented creation date for entity + /// Creation Date /// - public interface IEasyCreateDateEntity - { - /// - /// Creation Date - /// - public DateTime CreationDate { get; set; } - } -} + public DateTime CreationDate { get; set; } +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/IEasyEntity.cs b/src/EasyRepository.EFCore.Abstractions/IEasyEntity.cs index dfece69..7fd46ff 100644 --- a/src/EasyRepository.EFCore.Abstractions/IEasyEntity.cs +++ b/src/EasyRepository.EFCore.Abstractions/IEasyEntity.cs @@ -1,16 +1,15 @@ -namespace EasyRepository.EFCore.Abstractions +namespace EasyRepository.EFCore.Abstractions; + +/// +/// This interface implemented primary key entity +/// +/// +/// Primary Key type of the entity +/// +internal interface IEasyEntity { /// - /// This interface implemented primary key entity + /// Primary Key /// - /// - /// Primary Key type of the entity - /// - internal interface IEasyEntity - { - /// - /// Primary Key - /// - TPrimaryKey Id { get; set; } - } -} + TPrimaryKey Id { get; set; } +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/IEasySoftDeleteEntity.cs b/src/EasyRepository.EFCore.Abstractions/IEasySoftDeleteEntity.cs index e343eef..05f7364 100644 --- a/src/EasyRepository.EFCore.Abstractions/IEasySoftDeleteEntity.cs +++ b/src/EasyRepository.EFCore.Abstractions/IEasySoftDeleteEntity.cs @@ -1,20 +1,19 @@ -using System; +namespace EasyRepository.EFCore.Abstractions; -namespace EasyRepository.EFCore.Abstractions +using System; + +/// +/// This interface implemented Deletion Date and Is Deleted property for entity +/// +public interface IEasySoftDeleteEntity { /// - /// This interface implemented Deletion Date and Is Deleted property for entity + /// Deletion Date /// - public interface IEasySoftDeleteEntity - { - /// - /// Deletion Date - /// - public DateTime? DeletionDate { get; set; } + public DateTime? DeletionDate { get; set; } - /// - /// Is Deleted - /// - public bool IsDeleted { get; set; } - } -} + /// + /// Is Deleted + /// + public bool IsDeleted { get; set; } +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/IEasyUpdateDateEntity.cs b/src/EasyRepository.EFCore.Abstractions/IEasyUpdateDateEntity.cs index f95d226..f290f86 100644 --- a/src/EasyRepository.EFCore.Abstractions/IEasyUpdateDateEntity.cs +++ b/src/EasyRepository.EFCore.Abstractions/IEasyUpdateDateEntity.cs @@ -1,15 +1,14 @@ -using System; +namespace EasyRepository.EFCore.Abstractions; -namespace EasyRepository.EFCore.Abstractions +using System; + +/// +/// This interface implemented Modification Date property for entity +/// +public interface IEasyUpdateDateEntity { /// - /// This interface implemented Modification Date property for entity + /// Modification Date /// - public interface IEasyUpdateDateEntity - { - /// - /// Modification Date - /// - public DateTime? ModificationDate { get; set; } - } -} + public DateTime? ModificationDate { get; set; } +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Abstractions/IRepository.cs b/src/EasyRepository.EFCore.Abstractions/IRepository.cs index 7ed2587..aea6512 100644 --- a/src/EasyRepository.EFCore.Abstractions/IRepository.cs +++ b/src/EasyRepository.EFCore.Abstractions/IRepository.cs @@ -1,1672 +1,3208 @@ -using AutoFilterer.Types; -using Microsoft.EntityFrameworkCore.Query; +namespace EasyRepository.EFCore.Abstractions; + using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; +using AutoFilterer.Types; +using Enums; +using Microsoft.EntityFrameworkCore.Query; -namespace EasyRepository.EFCore.Abstractions +/// +/// This interface implemented base database operation with generic repository pattern +/// +public interface IRepository { /// - /// This interface implemented base database operation with generic repository pattern - /// - public interface IRepository - { - /// - /// This method takes and performs entity insert operation. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// The entity to be added - /// - /// - /// Returns - /// - TEntity Add(TEntity entity) where TEntity : class; - - /// - /// This method takes and performs entity insert async. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// The entity to be added - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes and performs entity insert operation. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// Type of entity primary key - /// - /// - /// The entity to be added - /// - /// - /// Returns - /// - TEntity Add(TEntity entity) where TEntity : EasyBaseEntity; - - /// - /// This method takes and performs entity insert operation async version. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// Type of entity primary key - /// - /// - /// The entity to be added - /// - /// A to observe while waiting for the task to complete. - /// - Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This methods takes and performs entity insert range operation. In additional this methods returns - /// - /// - /// Type of entity - /// - /// - /// The entity to be added - /// - /// - /// Returns - /// - IEnumerable AddRange(IEnumerable entities) where TEntity : class; - - /// - /// This method takes and performs entity insert range operation async version. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// The entities to be added - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes and performs entity insert range operation. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entities to be added - /// - /// - /// Returns - /// - IEnumerable AddRange(IEnumerable entities) where TEntity : EasyBaseEntity; - - /// - /// This method takes and performs entity insert range operation. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// Type of primary key - /// - /// - /// The entities to be added - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> AddRangeAsync(IEnumerable entites, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This method takes and performs entity hard delete operation. - /// - /// - /// Type of entity - /// - /// - /// The entity to be deleted - /// - void HardDelete(TEntity entity) where TEntity : class; - - /// - /// This method takes and . This method performs entity hard delete operation. In additional this methods returns - /// - /// - /// Type of entity - /// - /// - /// The entity to be deleted - /// - /// - /// Returns - /// - Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes and performs entity hard delete operation - /// - /// - /// PK of Entity - /// - void HardDelete(object id) where TEntity : class; - - /// - /// This method takes an . This method performs hard delete operation async version. In additional returns - /// - /// - /// Pk of Entity - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task HardDeleteAsync(object id, CancellationToken cancellationToken = default) where TEntity : class; - - - /// - /// This method takes and performs hard delete operation - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key for Entity - /// - /// - /// The entity to be deleted - /// - void HardDelete(TEntity entity) where TEntity : EasyBaseEntity; - - /// - /// This method takes and performs hard delete operation async version for EasyBaseEntity. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entity to be deleted - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This method takes and performs hard delete operation by id. - /// - /// - /// Type of entity - /// - /// - /// Type of Primary Key - /// - /// - /// PK of Entity - /// - void HardDelete(TPrimaryKey id) where TEntity : EasyBaseEntity; - - /// - /// This method takes and . This method performs hard delete operation by id async version. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// PK of Entity - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task HardDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - - /// - /// This method takes and performs soft delete operation - /// - /// - /// Type of entity - /// - /// - /// Type of Primary Key - /// - /// - /// PK of Entity - /// - void SoftDelete(TEntity entity) where TEntity : EasyBaseEntity; - - /// - /// This method takes performs soft delete operation. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entity to be deleted - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task SoftDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This method takes and performs soft delete operation by id. - /// - /// - /// Type of entity - /// - /// - /// Type of Primary Key - /// - /// - /// PK of Entity - /// - void SoftDelete(TPrimaryKey id) where TEntity : EasyBaseEntity; - - /// - /// This method takes and . This method performs soft delete operation by id async version. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// PK of Entity - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task SoftDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This method takes performs update operation. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// The entity to be updated - /// - TEntity Update(TEntity entity) where TEntity : class; - - /// - /// This method takes and performs update operation async version. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// The entity to be updated - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes performs update operation. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// The entities to be updated - /// - IEnumerable UpdateRange(IEnumerable entities) where TEntity : class; - - /// - /// This method takes and performs update operation async version. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// The entities to be updated - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes and . This method performs update operation for EasyBaseEntity. In additional this method returs - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entity to be updated - /// - /// - /// Returns - /// - TEntity Update(TEntity entity) where TEntity : EasyBaseEntity; - - /// - /// This method takes and . This method performs update operation for EasyBaseEntity. In additional this method returs - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entity to be updated - /// - /// - /// Returns - /// - Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This method takes and . This method performs update range operation for EasyBaseEntity. In additional this method returs - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entities to be updated - /// - /// - /// Returns - /// - IEnumerable UpdateRange(IEnumerable entities) where TEntity : EasyBaseEntity; - - /// - /// This method takes and . This method performs update operation for EasyBaseEntity. In additional this method returs - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entites to be updated - /// - /// - /// Returns - /// - Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - /// - /// This method takes performs replace operation. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// The entity to be replaced - /// - TEntity Replace(TEntity entity) where TEntity : class; - - - /// - /// This method takes and performs replace operation async version. In additional this methods returns - /// - /// - /// Type of Entity - /// - /// - /// The entity to be replaced - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes and . This method performs replace operation for EasyBaseEntity. In additional this method returs - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entity to be replaced - /// - /// - /// Returns - /// - TEntity Replace(TEntity entity) where TEntity : EasyBaseEntity; - - /// - /// This method takes and . This method performs replace operation for EasyBaseEntity. In additional this method returs - /// - /// - /// Type of Entity - /// - /// - /// Type of Primary Key - /// - /// - /// The entity to be replaced - /// - /// - /// Returns - /// - Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity; - - - /// - /// This method provides entity queryable version. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Returns - /// - IQueryable GetQueryable() where TEntity : class; - - /// - /// This method takes and apply filter to data source. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// The filter to apply on the Entity. - /// - /// - /// Returns - /// - IQueryable GetQueryable(Expression> filter) where TEntity : class; - - /// - /// This method returns List of Entity without filter. - /// - /// - /// Type of Entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking) where TEntity : class; - - /// - /// This method returns List of Entity without filter async version. - /// - /// - /// Type of Entity - /// - /// A to observe while waiting for the task to complete. - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method provides without filter get all entity but you can convert it to any object you want. - /// In additional this method takes returns - /// - /// - /// Type of Entity - /// - /// - /// Type of projected object - /// - /// - /// Select expression - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, Expression> projectExpression) where TEntity : class; - - /// - /// This method takes and . This method performs without filter get all entity but you can convert it to any object you want - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Select expression - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes performs apply filter get all entity. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Where expression see - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, Expression> whereExpression) where TEntity : class; - - /// - /// This method takes and . This method performs apply filter get all entity. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Where Expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes where expression and select expression. This method performs apply filter and convert returns get all entity. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of Projected object - /// - /// - /// Where Expression - /// - /// - /// Select expression - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) where TEntity : class; - - /// - /// This method takes where expression and select expression. This method performs apply filter async version and convert returns get all entity. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of Projected object - /// - /// - /// Where Expression - /// - /// - /// Select expression - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes and . This method performs get all with includable entities. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// expression - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, Func, IIncludableQueryable> includeExpression) where TEntity : class; - - /// - /// This method takes and . This method performs get all with includable entities async version. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes , and . This method perform get all entities with filter and includable entities. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where Expression - /// - /// - /// Include expression - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class; - - /// - /// This method takes , , and . This method perform get all entities with filter and includable entities async version. In additional this method returns - /// - /// - /// Type of Entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where Expression - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking, where expression, include expression and select expression. This method perform get all projected object with filter and include entities. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where Expression - /// - /// - /// Include expression - /// - /// - /// Select expression - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, Expression> projectExpression) where TEntity : class; - - /// - /// This method takes asNoTracking, where expression, include expression, select expression and cancellation token. This method perform get all projected object with filter and include entities async version. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where Expression - /// - /// - /// Include expression - /// - /// - /// Select expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking, pagination filter object. This method performs generate LINQ expressions for Entities over DTOs automatically. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of filter object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, TFilter filter) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, pagination filter object and . This method performs generate LINQ expressions for Entities over DTOs automatically async version. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of filter object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, pagination filter object and include expression. This method performs get all entities with apply filter and includable entities. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of filter Object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Include expression - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, paginationable filter object, and cancellation token. This method performs get all entities with apply filter and get all includable entities async version. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of filter object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, paginationable filter object and project expression. This method performs get all projected objects with apply filter. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of filter Object - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Project expression - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, TFilter filter, Expression> projectExpression) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, paginationable filter object and project expression. This method performs get all projected objects with apply filter async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of filter Object - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Project expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, paginationable filter object, project expression and include expression. This method performs get all projected objects with apply filter and get all includable entities. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of filter - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Project expression - /// - /// - /// Include expression - /// - /// - /// Returns - /// - List GetMultiple(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, paginationable filter object, project expression and include expression. This method performs get all projected objects with apply filter and get all includable entities async version. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of filter - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter dto - /// - /// - /// Project expression - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task> GetMultipleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - - /// - /// This method takes asNoTracking and where expression. This method performs get entity with apply filter. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Returns - /// - TEntity GetSingle(bool asNoTracking, Expression> whereExpression) where TEntity : class; - - /// - /// This method takes asNoTracking and where expression. This method performs get entity with apply filter async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking, and include expression. This method performs get entity with apply filter and includable entities. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Include expression - /// - /// - /// Returns - /// - TEntity GetSingle(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class; - - /// - /// This method takes asNoTracking, and include expression. This method performs get entity with apply filter and includable entities async version. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking, where expression and project the expression. This method performs get projected object with apply filter. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Project expression - /// - /// - /// Returns - /// - TProjected GetSingle(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) where TEntity : class; - - /// - /// This method takes asNoTracking, where expression, project the expression and cancellation token. This method performs get projected object with apply filter async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Project expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking, where expression, project expression and include expression. This method performs get projected object with apply filter and includable entity. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Project expression - /// - /// - /// Include expression - /// - /// - /// Returns - /// - TProjected GetSingle(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class; - - - /// - /// This method takes asNoTracking, where expression, project expression, include expression and cancellation token. This method performs get projected object with apply filter and includable entity async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Where expression - /// - /// - /// Project expression - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking and filter object. This object must be type . This method perform get entity with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// - /// Returns - /// - TEntity GetSingle(bool asNoTracking, TFilter filter) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, cancellation token and filter object. This object must be type . This method perform get entity with filter async version. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, include expression and filterable object . This method performs get and includable entity with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// - /// Include expression - /// - /// - /// Returns - /// - TEntity GetSingle(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, include expression, cancellation token and filterable object . This method performs get and includable entity with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, select expression and filterable object . This method performs get projected object with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// - /// Returns - /// - TProjected GetSingle(bool asNoTracking, TFilter filter, Expression> projectExpression) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, select expression, cancellation token and filterable object . This method performs get projected object with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, select expression, include expression and filterable object . This method performs get projected object with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// - /// Include expression - /// - /// - /// Returns - /// - TProjected GetSingle(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes asNoTracking, select expression, include expression, cancellation token and filterable object . This method performs get projected object with filter. In additional returns - /// - /// - /// Type of Entity - /// - /// - /// Type of Filter - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// Filter object of type FilterBase - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetSingleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - - /// - /// This method takes asNoTracking and id. This method provides get entity by id. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Returns - /// - TEntity GetById(bool asNoTracking, object id) where TEntity : class; - - /// - /// This method takes asNoTracking, id. This method provides get entity by id async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetByIdAsync(bool asNoTracking, object id, CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes asNoTracking, id and include expression. This method performs get entity by id with includable entities. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by the EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Include expression - /// - /// - /// Returns - /// - TEntity GetById(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression) where TEntity : class; - - /// - /// This method takes asNoTracking, id, include expression and cancellation token. This method performs get entity by id with includable entities. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Do you want the entity to be tracked by the EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Include expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetByIdAsync(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class; - - - /// - /// This method takes asnoTracking, id and project expression. This method performs get projected object by id with includable entities. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by the EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Project expression - /// - /// - /// Returns - /// - TProjected GetById(bool asNoTracking, object id, Expression> projectExpression) where TEntity : class; - - /// - /// This method takes asnoTracking, id and project expression. This method performs get projected object by id with includable entities async version. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by the EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Project expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetByIdAsync(bool asNoTracking, object id, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class; - - - /// - /// This method takes asnoTracking, id, and project expression. This method performs get projected object by id with includable entities. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by the EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Include expression - /// - /// - /// Project expression - /// - /// - /// Returns - /// - TProjected GetById(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, Expression> projectExpression) where TEntity : class; - - /// - /// This method takes asnoTracking, id, and project expression. This method performs get projected object by id with includable entities async version. In additional this method returns - /// - /// - /// Type of entity - /// - /// - /// Type of projected object - /// - /// - /// Do you want the entity to be tracked by the EF Core? Default value : false - /// - /// - /// PK of entity - /// - /// - /// Include expression - /// - /// - /// Project expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task GetByIdAsync(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class; - - - /// - /// This method takes any expression. This method perform exist operation for condition. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Any expression - /// - /// - /// Returns - /// - bool Any(Expression> anyExpression) where TEntity : class; - - /// - /// This method takes any expression and cancellation token. This method perform exist operation for condition. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Any expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task AnyAsync(Expression> anyExpression, CancellationToken cancellationToken = default) where TEntity : class; - - - /// - /// This method performs get count information of entity. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Returns - /// - int Count() where TEntity : class; - - /// - /// This method takes cancellation token.This method performs get count information of entity async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// A to observe while waiting for the task to complete. - /// Returns - /// - Task CountAsync(CancellationToken cancellationToken = default) where TEntity : class; - - /// - /// This method takes . This method performs get count information of entity with filter. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Where expression - /// - /// - /// Returns - /// - int Count(Expression> whereExpression) where TEntity : class; - - /// - /// This method takes and cancellation token. This method performs get count information of entity with filter async version. In additional returns - /// - /// - /// Type of entity - /// - /// - /// Where expression - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task Count(Expression> whereExpression, CancellationToken cancellationToken = default) where TEntity : class; - - - /// - /// This method takes filterable object. This object must be inheritance . This method performs get count information of entity with filter. In additional - /// - /// - /// Type of Entity - /// - /// - /// Type of filterable object - /// - /// - /// Filterable object - /// - /// - /// Returns - /// - int Count(TFilter filter) where TEntity : class where TFilter : FilterBase; - - /// - /// This method takes cancellation token and filterable object. This object must be inheritance . This method performs get count information of entity with filter async version. In additional - /// - /// - /// Type of Entity - /// - /// - /// Type of filterable object - /// - /// - /// Filterable object - /// - /// A to observe while waiting for the task to complete. - /// - /// Returns - /// - Task CountAsync(TFilter filter, CancellationToken cancellationToken = default) where TEntity : class where TFilter : FilterBase; - - /// - /// This method provides save changes for changes in current transaction - /// - void Complete(); - - /// - /// This method takes cancellation token in additional this method provides save changes for changes in current transactions - /// - /// A to observe while waiting for the task to complete. - /// - /// Task. - /// - Task CompleteAsync(CancellationToken cancellationToken = default); - } -} + /// This method takes and performs entity insert operation. In additional this methods returns + /// + /// + /// + /// Type of Entity + /// + /// + /// The entity to be added + /// + /// + /// Returns + /// + TEntity Add(TEntity entity) + where TEntity : class; + + /// + /// This method takes and performs entity insert operation. In additional + /// this methods returns + /// + /// + /// Type of Entity + /// + /// + /// Type of entity primary key + /// + /// + /// The entity to be added + /// + /// + /// Returns + /// + TEntity Add(TEntity entity) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and performs entity insert async. In additional this methods returns + /// + /// + /// + /// Type of Entity + /// + /// + /// The entity to be added + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and performs entity insert operation async version. In + /// additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// Type of entity primary key + /// + /// + /// The entity to be added + /// + /// A to observe while waiting for the task to complete. + /// + Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + /// + /// This methods takes and performs entity insert range operation. In additional + /// this methods returns + /// + /// + /// Type of entity + /// + /// + /// The entity to be added + /// + /// + /// Returns + /// + IEnumerable AddRange(IEnumerable entities) + where TEntity : class; + + /// + /// This method takes and performs entity insert range + /// operation. In additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entities to be added + /// + /// + /// Returns + /// + IEnumerable AddRange(IEnumerable entities) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and performs entity insert range operation async version. In + /// additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// The entities to be added + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and performs entity insert range + /// operation. In additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// Type of primary key + /// + /// + /// The entities to be added + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + + /// + /// This method takes any expression. This method perform exist operation for + /// condition. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Any expression + /// + /// + /// Returns + /// + bool Any(Expression> anyExpression) + where TEntity : class; + + /// + /// This method takes any expression and cancellation + /// token. This method perform exist operation for condition. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Any expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task AnyAsync(Expression> anyExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method provides save changes for changes in current transaction + /// + void Complete(); + + /// + /// This method takes cancellation token in additional this method provides save + /// changes for changes in current transactions + /// + /// A to observe while waiting for the task to complete. + /// + /// Task. + /// + Task CompleteAsync(CancellationToken cancellationToken = default); + + + /// + /// This method performs get count information of entity. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Returns + /// + int Count() + where TEntity : class; + + /// + /// This method takes . This method performs get count information of entity with + /// filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Where expression + /// + /// + /// Returns + /// + int Count(Expression> whereExpression) + where TEntity : class; + + /// + /// This method takes and cancellation token. This + /// method performs get count information of entity with filter async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Where expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task CountAsync(Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes filterable object. This object must be inheritance + /// . This method performs get count information of entity with filter. In additional + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of filterable object + /// + /// + /// Filterable object + /// + /// + /// Returns + /// + int Count(TFilter filter) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes cancellation token.This method performs get count information of + /// entity async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// + /// A to observe while waiting for the task to + /// complete. + /// + /// Returns + /// + Task CountAsync(CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes cancellation token and filterable + /// object. This object must be inheritance . This method performs get count information of + /// entity with filter async version. In additional + /// + /// + /// Type of Entity + /// + /// + /// Type of filterable object + /// + /// + /// Filterable object + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task CountAsync(TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking and id. This method provides get entity by + /// id. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// + /// Returns + /// + TEntity GetById(bool asNoTracking, object id) + where TEntity : class; + + + /// + /// This method takes asNoTracking and id. This method provides get entity by + /// id. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// PK of entity + /// + /// + /// Returns + /// + TEntity GetById(EfTrackingOptions asNoTracking, object id) + where TEntity : class; + + /// + /// This method takes asNoTracking, id and + /// include expression. This method performs get entity by id + /// with includable entities. In additional this method returns + /// + /// {TEntity} + /// + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by the EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// + /// Returns + /// + /// {TEntity} + /// + /// + TEntity GetById(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id and + /// include expression. This method performs get entity by id + /// with includable entities. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TEntity GetById(EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id and + /// project expression. This method performs get projected object by id with includable entities. In additional this + /// method returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// + /// Project expression + /// + /// + /// Returns + /// + TProjected GetById(bool asNoTracking, object id, Expression> projectExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id and + /// project expression. This method performs get projected object by id with includable entities. In additional this + /// method returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Project expression + /// + /// + /// Returns + /// + TProjected GetById(EfTrackingOptions asNoTracking, object id, Expression> projectExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id, + /// and project expression. + /// This method performs get projected object by id with includable entities. In additional this method returns + /// + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// + /// Project expression + /// + /// + /// Returns + /// + TProjected GetById( + bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id, + /// and project expression. + /// This method performs get projected object by id with includable entities. In additional this method returns + /// + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// + /// Project expression + /// + /// + /// Returns + /// + TProjected GetById( + EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, id. This method provides get entity by id + /// async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync(bool asNoTracking, object id, CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id. This method provides get entity by id + /// async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// PK of entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync(EfTrackingOptions asNoTracking, object id, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, id, + /// include expression and + /// cancellation token. This method performs get entity by id with includable entities. In additional this method + /// returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync( + bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id, + /// include expression and + /// cancellation token. This method performs get entity by id with includable entities. In additional this method + /// returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync( + EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id and + /// project expression. This method performs get projected object by id with includable entities async version. In + /// additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync( + bool asNoTracking, object id, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, id and + /// project expression. This method performs get projected object by id with includable entities async version. In + /// additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync( + EfTrackingOptions asNoTracking, object id, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, id, + /// and project expression. + /// This method performs get projected object by id with includable entities async version. In additional this method + /// returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? Default value : false + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync( + bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, id, + /// and project expression. + /// This method performs get projected object by id with includable entities async version. In additional this method + /// returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by the EF Core? + /// + /// + /// PK of entity + /// + /// + /// Include expression + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetByIdAsync( + EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method returns List of Entity without filter. + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking) + where TEntity : class; + + /// + /// This method returns List of Entity without filter. + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking) + where TEntity : class; + + /// + /// This method provides without filter get all entity but you can convert it to any object you want. + /// In additional this method takes returns + /// + /// + /// Type of Entity + /// + /// + /// Type of projected object + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, Expression> projectExpression) + where TEntity : class; + + /// + /// This method provides without filter get all entity but you can convert it to any object you want. + /// In additional this method takes returns + /// + /// + /// Type of Entity + /// + /// + /// Type of projected object + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, Expression> projectExpression) + where TEntity : class; + + + /// + /// This method takes performs apply filter get all entity. In additional returns + /// + /// + /// + /// Type of entity + /// + /// + /// Where expression see + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, Expression> whereExpression) + where TEntity : class; + + /// + /// This method takes performs apply filter get all entity. In additional returns + /// + /// + /// + /// Type of entity + /// + /// + /// Where expression see + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, Expression> whereExpression) + where TEntity : class; + + /// + /// This method takes where expression and select + /// expression. This method performs apply filter and convert returns get all entity. In additional returns + /// + /// + /// + /// Type of entity + /// + /// + /// Type of Projected object + /// + /// + /// Where Expression + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class; + + /// + /// This method takes where expression and select + /// expression. This method performs apply filter and convert returns get all entity. In additional returns + /// + /// + /// + /// Type of entity + /// + /// + /// Type of Projected object + /// + /// + /// Where Expression + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class; + + + /// + /// This method takes and . This method + /// performs get all with includable entities. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// expression + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes and . This method + /// performs get all with includable entities. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// expression + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes , and + /// . This method perform get all entities with filter and + /// includable entities. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes , and + /// . This method perform get all entities with filter and + /// includable entities. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + List GetMultiple( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, where expression, + /// include expression and + /// select expression. This method perform get all projected object with filter and include entities. In additional + /// returns + /// + /// + /// Type of Entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// + /// Select expression + /// + /// + /// Returns + /// + List GetMultiple( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression, + /// include expression and + /// select expression. This method perform get all projected object with filter and include entities. In additional + /// returns + /// + /// + /// Type of Entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// + /// Select expression + /// + /// + /// Returns + /// + List GetMultiple( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class; + + + /// + /// This method takes asNoTracking, pagination filter object. This method + /// performs generate LINQ expressions for Entities over DTOs automatically. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of filter object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, pagination filter object. This method + /// performs generate LINQ expressions for Entities over DTOs automatically. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of filter object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, pagination filter object and + /// include expression. This method performs get all entities + /// with apply filter and includable entities. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter Object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Include expression + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, pagination filter object and + /// include expression. This method performs get all entities + /// with apply filter and includable entities. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter Object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Include expression + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, paginationable filter object and + /// project expression. This method performs get all projected objects with apply + /// filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter Object + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// + /// Returns + /// + List GetMultiple(bool asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object and + /// project expression. This method performs get all projected objects with apply + /// filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter Object + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// + /// Returns + /// + List GetMultiple(EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, paginationable filter object, + /// project expression and + /// include expression. This method performs get all projected objects with apply filter and get all includable + /// entities. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + List GetMultiple( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object, + /// project expression and + /// include expression. This method performs get all projected objects with apply filter and get all includable + /// entities. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + List GetMultiple( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method returns List of Entity without filter async version. + /// + /// + /// Type of Entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Returns + /// + Task> GetMultipleAsync(bool asNoTracking, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method returns List of Entity without filter async version. + /// + /// + /// Type of Entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Returns + /// + Task> GetMultipleAsync(EfTrackingOptions asNoTracking, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method performs + /// without filter get all entity but you can convert it to any object you want + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync(bool asNoTracking, Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method performs + /// without filter get all entity but you can convert it to any object you want + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync(EfTrackingOptions asNoTracking, Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes and . This method performs apply + /// filter get all entity. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Where Expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Returns + /// + Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method performs apply + /// filter get all entity. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Where Expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Returns + /// + Task> GetMultipleAsync(EfTrackingOptions asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes where expression and select + /// expression. This method performs apply filter async version and convert returns get all entity. In additional + /// returns + /// + /// + /// Type of entity + /// + /// + /// Type of Projected object + /// + /// + /// Where Expression + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// The cancellation token + /// + /// Returns + /// + Task> GetMultipleAsync( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes where expression and select + /// expression. This method performs apply filter async version and convert returns get all entity. In additional + /// returns + /// + /// + /// Type of entity + /// + /// + /// Type of Projected object + /// + /// + /// Where Expression + /// + /// + /// Select expression + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// The cancellation token + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method + /// performs get all with includable entities async version. In additional this method returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync(bool asNoTracking, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method + /// performs get all with includable entities async version. In additional this method returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes , , + /// and . This method perform + /// get all entities with filter and includable entities async version. In additional this method returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes , , + /// and . This method perform + /// get all entities with filter and includable entities async version. In additional this method returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, where expression, + /// include expression, select + /// expression and cancellation token. This method perform get all projected object + /// with filter and include entities async version. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// + /// Select expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, where expression, + /// include expression, select + /// expression and cancellation token. This method perform get all projected object + /// with filter and include entities async version. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where Expression + /// + /// + /// Include expression + /// + /// + /// Select expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, pagination filter object and + /// . This method performs generate LINQ expressions for Entities over DTOs + /// automatically async version. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of filter object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, pagination filter object and + /// . This method performs generate LINQ expressions for Entities over DTOs + /// automatically async version. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of filter object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync(EfTrackingOptions asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object, + /// and cancellation token. + /// This method performs get all entities with apply filter and get all includable entities async version. In + /// additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object, + /// and cancellation token. + /// This method performs get all entities with apply filter and get all includable entities async version. In + /// additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object and + /// project expression. This method performs get all projected objects with apply + /// filter async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter Object + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object and + /// project expression. This method performs get all projected objects with apply + /// filter async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter Object + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, paginationable filter object, + /// project expression and + /// include expression. This method performs get all projected objects with apply filter and get all includable + /// entities async version. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, paginationable filter object, + /// project expression and + /// include expression. This method performs get all projected objects with apply filter and get all includable + /// entities async version. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Type of filter + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter dto + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method provides entity queryable version. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Returns + /// + IQueryable GetQueryable() + where TEntity : class; + + /// + /// This method takes and apply filter to data source. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// The filter to apply on the Entity. + /// + /// + /// Returns + /// + IQueryable GetQueryable(Expression> filter) + where TEntity : class; + + + /// + /// This method takes asNoTracking and where expression. This + /// method performs get entity with apply filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Returns + /// + TEntity GetSingle(bool asNoTracking, Expression> whereExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking and where expression. This + /// method performs get entity with apply filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Returns + /// + TEntity GetSingle(EfTrackingOptions asNoTracking, Expression> whereExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, and + /// include expression. This method performs get entity with + /// apply filter and includable entities. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TEntity GetSingle(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, and + /// include expression. This method performs get entity with + /// apply filter and includable entities. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TEntity GetSingle(EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression and + /// project the expression. This method performs get projected object with apply + /// filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// + /// Returns + /// + TProjected GetSingle(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression and + /// project the expression. This method performs get projected object with apply + /// filter. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// + /// Returns + /// + TProjected GetSingle(EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression, + /// project expression and + /// include expression. This method performs get projected object with apply filter and includable entity. In + /// additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TProjected GetSingle( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression, + /// project expression and + /// include expression. This method performs get projected object with apply filter and includable entity. In + /// additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TProjected GetSingle( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class; + + /// + /// This method takes asNoTracking and filter object. This object must be + /// type . This method perform get entity with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Returns + /// + TEntity GetSingle(bool asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking and filter object. This object must be + /// type . This method perform get entity with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Returns + /// + TEntity GetSingle(EfTrackingOptions asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, include + /// expression and filterable object . This method performs get and + /// includable entity with filter. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TEntity GetSingle(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, include + /// expression and filterable object . This method performs get and + /// includable entity with filter. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TEntity GetSingle(EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, select expression and + /// filterable object . This method performs get projected object + /// with filter. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projection to return + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Returns + /// + TProjected GetSingle(bool asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, select expression and + /// filterable object . This method performs get projected object + /// with filter. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projection to return + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Returns + /// + TProjected GetSingle(EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, select expression, + /// include expression and filterable + /// object . This method performs get projected object with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projection to return + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TProjected GetSingle( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, select expression, + /// include expression and filterable + /// object . This method performs get projected object with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projection to return + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Include expression + /// + /// + /// Returns + /// + TProjected GetSingle( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking and where expression. This + /// method performs get entity with apply filter async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking and where expression. This + /// method performs get entity with apply filter async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync(EfTrackingOptions asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, and + /// include expression. This method performs get entity with + /// apply filter and includable entities async version. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, and + /// include expression. This method performs get entity with + /// apply filter and includable entities async version. In additional this method returns + /// + /// + /// Type of entity + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression, + /// project the expression and cancellation token. + /// This method performs get projected object with apply filter async version. In additional returns + /// + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression, + /// project the expression and cancellation token. + /// This method performs get projected object with apply filter async version. In additional returns + /// + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class; + + + /// + /// This method takes asNoTracking, where expression, + /// project expression, include + /// expression and cancellation token. This method performs get projected object with + /// apply filter and includable entity async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, where expression, + /// project expression, include + /// expression and cancellation token. This method performs get projected object with + /// apply filter and includable entity async version. In additional returns + /// + /// + /// Type of entity + /// + /// + /// Type of projected object + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Where expression + /// + /// + /// Project expression + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes asNoTracking, cancellation token and + /// filter object. This object must be type . This method perform get + /// entity with filter async version. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, cancellation token and + /// filter object. This object must be type . This method perform get + /// entity with filter async version. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync(EfTrackingOptions asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, include + /// expression, cancellation token and filterable object + /// . This method performs get and includable entity with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, include + /// expression, cancellation token and filterable object + /// . This method performs get and includable entity with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, select expression, + /// cancellation token and filterable object + /// . This method performs get projected object with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projected type to return + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, select expression, + /// cancellation token and filterable object + /// . This method performs get projected object with filter. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projected type to return + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + + /// + /// This method takes asNoTracking, select expression, + /// include expression, + /// cancellation token and filterable object . This method performs + /// get projected object with filter. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projected type to return + /// + /// Do you want the entity to be tracked by EF Core? Default value : false + /// + /// + /// Filter object of type FilterBase + /// + /// The expression to create the projection object + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes asNoTracking, select expression, + /// include expression, + /// cancellation token and filterable object . This method performs + /// get projected object with filter. In additional returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Filter + /// + /// The projected type to return + /// + /// Do you want the entity to be tracked by EF Core? + /// + /// + /// Filter object of type FilterBase + /// + /// The expression to create the projection object + /// + /// Include expression + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task GetSingleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase; + + /// + /// This method takes and performs entity hard delete operation. + /// + /// + /// Type of entity + /// + /// + /// The entity to be deleted + /// + void HardDelete(TEntity entity) + where TEntity : class; + + /// + /// This method takes and performs entity hard delete operation + /// + /// + /// PK of Entity + /// + void HardDelete(object id) + where TEntity : class; + + + /// + /// This method takes and performs hard delete operation + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key for Entity + /// + /// + /// The entity to be deleted + /// + void HardDelete(TEntity entity) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and performs hard delete operation by id. + /// + /// + /// Type of entity + /// + /// + /// Type of Primary Key + /// + /// + /// PK of Entity + /// + void HardDelete(TPrimaryKey id) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and . This method performs entity hard + /// delete operation. In additional this methods returns + /// + /// + /// Type of entity + /// + /// + /// The entity to be deleted + /// + /// The cancellation token + /// + /// Returns + /// + Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes an . This method performs hard delete + /// operation async version. In additional returns + /// + /// + /// Pk of Entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task HardDeleteAsync(object id, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and performs hard delete operation async version for EasyBaseEntity. In + /// additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entity to be deleted + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and . This method performs hard + /// delete operation by id async version. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// PK of Entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task HardDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + /// + /// This method takes performs replace operation. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// The entity to be replaced + /// + TEntity Replace(TEntity entity) + where TEntity : class; + + /// + /// This method takes and . This method performs replace operation + /// for EasyBaseEntity. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entity to be replaced + /// + /// + /// Returns + /// + TEntity Replace(TEntity entity) + where TEntity : EasyBaseEntity; + + + /// + /// This method takes and performs replace operation async + /// version. In additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// The entity to be replaced + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method performs replace operation + /// for EasyBaseEntity. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entity to be replaced + /// + /// The cancellation token + /// + /// Returns + /// + Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + + /// + /// This method takes and performs soft delete operation + /// + /// + /// Type of entity + /// + /// + /// Type of Primary Key + /// + /// + /// PK of Entity + /// + /// + void SoftDelete(TEntity entity) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and performs soft delete operation by id. + /// + /// + /// Type of entity + /// + /// + /// Type of Primary Key + /// + /// + /// PK of Entity + /// + void SoftDelete(TPrimaryKey id) + where TEntity : EasyBaseEntity; + + /// + /// This method takes performs soft delete operation. In additional this method returns + /// + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entity to be deleted + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task SoftDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and . This method performs soft + /// delete operation by id async version. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// PK of Entity + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task SoftDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + /// + /// This method takes performs update operation. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// The entity to be updated + /// + TEntity Update(TEntity entity) + where TEntity : class; + + /// + /// This method takes and . This method performs update operation + /// for EasyBaseEntity. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entity to be updated + /// + /// + /// Returns + /// + TEntity Update(TEntity entity) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and performs update operation async + /// version. In additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// The entity to be updated + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method performs update operation + /// for EasyBaseEntity. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entity to be updated + /// + /// The cancellation token + /// + /// Returns + /// + Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; + + /// + /// This method takes performs update operation. In additional returns + /// + /// + /// + /// Type of Entity + /// + /// + /// The entities to be updated + /// + IEnumerable UpdateRange(IEnumerable entities) + where TEntity : class; + + /// + /// This method takes and . This method performs update + /// range operation for EasyBaseEntity. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entities to be updated + /// + /// + /// Returns + /// + IEnumerable UpdateRange(IEnumerable entities) + where TEntity : EasyBaseEntity; + + /// + /// This method takes and performs update + /// operation async version. In additional this methods returns + /// + /// + /// Type of Entity + /// + /// + /// The entities to be updated + /// + /// A to observe while waiting for the task to complete. + /// + /// Returns + /// + Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : class; + + /// + /// This method takes and . This method performs update + /// operation for EasyBaseEntity. In additional this method returns + /// + /// + /// Type of Entity + /// + /// + /// Type of Primary Key + /// + /// + /// The entities to be updated + /// + /// The cancellation token + /// + /// Returns + /// + Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity; +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Ardalis.Specification/SpecificationConverter.cs b/src/EasyRepository.EFCore.Ardalis.Specification/SpecificationConverter.cs index fb47b70..55ae476 100644 --- a/src/EasyRepository.EFCore.Ardalis.Specification/SpecificationConverter.cs +++ b/src/EasyRepository.EFCore.Ardalis.Specification/SpecificationConverter.cs @@ -1,30 +1,31 @@ -using System.Linq; -using Ardalis.Specification; -using Ardalis.Specification.EntityFrameworkCore; +namespace EasyRepository.EFCore.Ardalis.Specification; -namespace EasyRepository.EFCore.Ardalis.Specification; +using System.Linq; +using global::Ardalis.Specification; +using global::Ardalis.Specification.EntityFrameworkCore; /// -/// Specification Builder +/// Specification Builder /// public static class SpecificationConverter { /// - /// This method convert specification object to queryable object. + /// This method convert specification object to queryable object. /// /// - /// Entity + /// Entity /// /// - /// Specification object + /// Specification object /// /// - /// Entity + /// Entity /// /// - /// + /// /// - public static IQueryable Convert(IQueryable entity, ISpecification specification) where TEntity : class + public static IQueryable Convert(IQueryable entity, ISpecification specification) + where TEntity : class { return SpecificationEvaluator.Default.GetQuery(entity, specification); } diff --git a/src/EasyRepository.EFCore.Generic/Extensions/EfTrackingOptionExtensions.cs b/src/EasyRepository.EFCore.Generic/Extensions/EfTrackingOptionExtensions.cs new file mode 100644 index 0000000..a7b7397 --- /dev/null +++ b/src/EasyRepository.EFCore.Generic/Extensions/EfTrackingOptionExtensions.cs @@ -0,0 +1,11 @@ +namespace EasyRepository.EFCore.Generic.Extensions; + +using Abstractions.Enums; + +internal static class EfTrackingOptionExtensions +{ + public static bool HasNoTracking(this EfTrackingOptions options) + { + return options == EfTrackingOptions.AsNoTracking; + } +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Generic/IUnitOfWork.cs b/src/EasyRepository.EFCore.Generic/IUnitOfWork.cs index 544280a..bfa6f1d 100644 --- a/src/EasyRepository.EFCore.Generic/IUnitOfWork.cs +++ b/src/EasyRepository.EFCore.Generic/IUnitOfWork.cs @@ -1,9 +1,9 @@ -using EasyRepository.EFCore.Abstractions; +namespace EasyRepository.EFCore.Generic; -namespace EasyRepository.EFCore.Generic; +using Abstractions; /// -/// Abstraction of Unit Of Work pattern +/// Abstraction of Unit Of Work pattern /// public interface IUnitOfWork { diff --git a/src/EasyRepository.EFCore.Generic/Repository.cs b/src/EasyRepository.EFCore.Generic/Repository.cs index 2fad181..c142766 100644 --- a/src/EasyRepository.EFCore.Generic/Repository.cs +++ b/src/EasyRepository.EFCore.Generic/Repository.cs @@ -1,8 +1,5 @@ -using AutoFilterer.Extensions; -using AutoFilterer.Types; -using EasyRepository.EFCore.Abstractions; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Query; +namespace EasyRepository.EFCore.Generic; + using System; using System.Collections.Generic; using System.Globalization; @@ -10,641 +7,1609 @@ using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Storage; +using Abstractions; +using Abstractions.Enums; +using AutoFilterer.Extensions; +using AutoFilterer.Types; +using Extensions; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; -namespace EasyRepository.EFCore.Generic +/// +/// This class contains implementations of repository functions +/// +internal sealed class Repository : IRepository { + private readonly DbContext _context; + // public event Action SavingChanges = _ => { }; + /// - /// This class contains implementations of repository functions + /// Ctor /// - internal sealed class Repository : IRepository + /// + /// Database Context + /// + public Repository(DbContext context) { - private readonly DbContext _context; - - /// - /// Ctor - /// - /// - /// Database Context - /// - public Repository(DbContext context) - { - this._context = context; - } + this._context = context; + } - public TEntity Add(TEntity entity) where TEntity : class - { - _context.Set().Add(entity); - return entity; - } + public TEntity Add(TEntity entity) + where TEntity : class + { + this._context.Set() + .Add(entity); - public TEntity Add(TEntity entity) where TEntity : EasyBaseEntity - { - entity.CreationDate = DateTime.UtcNow; - _context.Set().Add(entity); - return entity; - } + return entity; + } - public async Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class - { - await _context.Set().AddAsync(entity, cancellationToken).ConfigureAwait(false); - return entity; - } + public TEntity Add(TEntity entity) + where TEntity : EasyBaseEntity + { + entity.CreationDate = DateTime.UtcNow; + this._context.Set() + .Add(entity); - public async Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - entity.CreationDate = DateTime.UtcNow; - await _context.Set().AddAsync(entity, cancellationToken).ConfigureAwait(false); - return entity; - } + return entity; + } - public IEnumerable AddRange(IEnumerable entities) where TEntity : class - { - _context.Set().AddRange(entities); - return entities; - } + public async Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class + { + await this._context.Set() + .AddAsync(entity, cancellationToken) + .ConfigureAwait(false); - public IEnumerable AddRange(IEnumerable entities) where TEntity : EasyBaseEntity - { - entities.ToList().ForEach(x => x.CreationDate = DateTime.UtcNow); - _context.Set().AddRange(entities); - return entities; - } + return entity; + } - public async Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : class - { - await _context.Set().AddRangeAsync(entities, cancellationToken).ConfigureAwait(false); - return entities; - } + public async Task AddAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + entity.CreationDate = DateTime.UtcNow; + await this._context.Set() + .AddAsync(entity, cancellationToken) + .ConfigureAwait(false); - public async Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - entities.ToList().ForEach(x => x.CreationDate = DateTime.UtcNow); - await _context.Set().AddRangeAsync(entities, cancellationToken).ConfigureAwait(false); - return entities; - } + return entity; + } - public bool Any(Expression> anyExpression) where TEntity : class - { - return _context.Set().Any(anyExpression); - } + public IEnumerable AddRange(IEnumerable entities) + where TEntity : class + { + this._context.Set() + .AddRange(entities); - public async Task AnyAsync(Expression> anyExpression, CancellationToken cancellationToken = default) where TEntity : class - { - bool result = await _context.Set().AnyAsync(anyExpression, cancellationToken).ConfigureAwait(false); - return result; - } + return entities; + } - public int Count() where TEntity : class - { - return _context.Set().Count(); - } + public IEnumerable AddRange(IEnumerable entities) + where TEntity : EasyBaseEntity + { + entities.ToList() + .ForEach(x => x.CreationDate = DateTime.UtcNow); + this._context.Set() + .AddRange(entities); - public int Count(Expression> whereExpression) where TEntity : class - { - return _context.Set().Where(whereExpression).Count(); - } + return entities; + } - public async Task Count(Expression> whereExpression, CancellationToken cancellationToken = default) where TEntity : class - { - int count = await _context.Set().Where(whereExpression).CountAsync(cancellationToken).ConfigureAwait(false); - return count; - } + public async Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : class + { + await this._context.Set() + .AddRangeAsync(entities, cancellationToken) + .ConfigureAwait(false); - public int Count(TFilter filter) - where TEntity : class - where TFilter : FilterBase - { - return _context.Set().ApplyFilter(filter).Count(); - } + return entities; + } - public async Task CountAsync(CancellationToken cancellationToken = default) where TEntity : class - { - int count = await _context.Set().CountAsync(cancellationToken).ConfigureAwait(false); - return count; - } + public async Task> AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + entities.ToList() + .ForEach(x => x.CreationDate = DateTime.UtcNow); + await this._context.Set() + .AddRangeAsync(entities, cancellationToken) + .ConfigureAwait(false); - public async Task CountAsync(TFilter filter, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - int count = await _context.Set().ApplyFilter(filter).CountAsync(cancellationToken).ConfigureAwait(false); - return count; - } + return entities; + } - public void Complete() - { - _context.SaveChanges(); - } + public bool Any(Expression> anyExpression) + where TEntity : class + { + return this._context.Set() + .Any(anyExpression); + } - public async Task CompleteAsync(CancellationToken cancellationToken = default) - { - await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); - } + public async Task AnyAsync(Expression> anyExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var result = await this._context.Set() + .AnyAsync(anyExpression, cancellationToken) + .ConfigureAwait(false); - private Expression> GenerateExpression(object id) - { - var type = _context.Model.FindEntityType(typeof(TEntity)); - string pk = type.FindPrimaryKey().Properties.Select(s => s.Name).FirstOrDefault(); - Type pkType = type.FindPrimaryKey().Properties.Select(p => p.ClrType).FirstOrDefault(); + return result; + } - object value = Convert.ChangeType(id, pkType, CultureInfo.InvariantCulture); + public int Count() + where TEntity : class + { + return this._context.Set() + .Count(); + } - ParameterExpression pe = Expression.Parameter(typeof(TEntity), "entity"); - MemberExpression me = Expression.Property(pe, pk); - ConstantExpression constant = Expression.Constant(value, pkType); - BinaryExpression body = Expression.Equal(me, constant); - Expression> expression = Expression.Lambda>(body, new[] { pe }); + public int Count(Expression> whereExpression) + where TEntity : class + { + return this._context.Set() + .Where(whereExpression) + .Count(); + } - return expression; - } + public async Task CountAsync(Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var count = await this._context.Set() + .Where(whereExpression) + .CountAsync(cancellationToken) + .ConfigureAwait(false); - public void HardDelete(TEntity entity) where TEntity : class - { - _context.Set().Remove(entity); - } + return count; + } - public void HardDelete(object id) where TEntity : class - { - var entity = _context.Set().Find(id); - _context.Set().Remove(entity); - } + public int Count(TFilter filter) + where TEntity : class + where TFilter : FilterBase + { + return this._context.Set() + .ApplyFilter(filter) + .Count(); + } - public void HardDelete(TEntity entity) where TEntity : EasyBaseEntity - { - _context.Set().Remove(entity); - } + public async Task CountAsync(CancellationToken cancellationToken = default) + where TEntity : class + { + var count = await this._context.Set() + .CountAsync(cancellationToken) + .ConfigureAwait(false); - public void HardDelete(TPrimaryKey id) where TEntity : EasyBaseEntity - { - var entity = _context.Set().FirstOrDefault(GenerateExpression(id)); - _context.Set().Remove(entity); - } + return count; + } - public Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class - { - _context.Set().Remove(entity); - return Task.CompletedTask; - } + public async Task CountAsync(TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var count = await this._context.Set() + .ApplyFilter(filter) + .CountAsync(cancellationToken) + .ConfigureAwait(false); - public async Task HardDeleteAsync(object id, CancellationToken cancellationToken = default) where TEntity : class - { - var entity = await _context.Set().FirstOrDefaultAsync(GenerateExpression(id), cancellationToken).ConfigureAwait(false); - _context.Set().Remove(entity); - } + return count; + } - public Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - _context.Set().Remove(entity); - return Task.CompletedTask; - } + public void Complete() + { + this._context.SaveChanges(); + } - public async Task HardDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - var entity = await _context.Set().FirstOrDefaultAsync(GenerateExpression(id), cancellationToken).ConfigureAwait(false); - _context.Set().Remove(entity); - } - public TEntity Replace(TEntity entity) where TEntity : class - { - _context.Entry(entity).State = EntityState.Modified; - return entity; - } + public async Task CompleteAsync(CancellationToken cancellationToken = default) + { + await this._context.SaveChangesAsync(cancellationToken) + .ConfigureAwait(false); + } - public TEntity Replace(TEntity entity) where TEntity : EasyBaseEntity - { - entity.ModificationDate = DateTime.UtcNow; - _context.Entry(entity).State = EntityState.Modified; - return entity; - } + /// + public async Task GetSingleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); - public Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class - { - _context.Entry(entity).State = EntityState.Modified; - return Task.FromResult(entity); - } + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } - public Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - entity.ModificationDate = DateTime.UtcNow; - _context.Entry(entity).State = EntityState.Modified; - return Task.FromResult(entity); - } + public void HardDelete(TEntity entity) + where TEntity : class + { + this._context.Set() + .Remove(entity); + } - public void SoftDelete(TEntity entity) where TEntity : EasyBaseEntity - { - entity.IsDeleted = true; - entity.DeletionDate = DateTime.UtcNow; - Replace(entity); - } + public void HardDelete(object id) + where TEntity : class + { + var entity = this._context.Set() + .Find(id); + this._context.Set() + .Remove(entity); + } - public void SoftDelete(TPrimaryKey id) where TEntity : EasyBaseEntity - { - var entity = _context.Set().FirstOrDefault(GenerateExpression(id)); - entity.IsDeleted = true; - entity.DeletionDate = DateTime.UtcNow; - Replace(entity); - } + public void HardDelete(TEntity entity) + where TEntity : EasyBaseEntity + { + this._context.Set() + .Remove(entity); + } - public async Task SoftDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - entity.IsDeleted = true; - entity.DeletionDate = DateTime.UtcNow; - await ReplaceAsync(entity, cancellationToken).ConfigureAwait(false); - } + public void HardDelete(TPrimaryKey id) + where TEntity : EasyBaseEntity + { + var entity = this._context.Set() + .FirstOrDefault(this.GenerateExpression(id)); + this._context.Set() + .Remove(entity); + } - public async Task SoftDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - var entity = await _context.Set().FirstOrDefaultAsync(GenerateExpression(id), cancellationToken).ConfigureAwait(false); ; - entity.IsDeleted = true; - entity.DeletionDate = DateTime.UtcNow; - await ReplaceAsync(entity, cancellationToken).ConfigureAwait(false); - } + public Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class + { + this._context.Set() + .Remove(entity); - public TEntity Update(TEntity entity) where TEntity : class - { - _context.Set().Update(entity); - return entity; - } + return Task.CompletedTask; + } - public TEntity Update(TEntity entity) where TEntity : EasyBaseEntity - { - entity.ModificationDate = DateTime.UtcNow; - _context.Set().Update(entity); - return entity; - } + public async Task HardDeleteAsync(object id, CancellationToken cancellationToken = default) + where TEntity : class + { + var entity = await this._context.Set() + .FirstOrDefaultAsync(this.GenerateExpression(id), cancellationToken) + .ConfigureAwait(false); + this._context.Set() + .Remove(entity); + } - public Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : class - { - _context.Set().Update(entity); - return Task.FromResult(entity); - } + public Task HardDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + this._context.Set() + .Remove(entity); - public Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - entity.ModificationDate = DateTime.UtcNow; - _context.Set().Update(entity); - return Task.FromResult(entity); - } + return Task.CompletedTask; + } - public IEnumerable UpdateRange(IEnumerable entities) where TEntity : class - { - _context.Set().UpdateRange(entities); - return entities; - } + public async Task HardDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + var entity = await this._context.Set() + .FirstOrDefaultAsync(this.GenerateExpression(id), cancellationToken) + .ConfigureAwait(false); + this._context.Set() + .Remove(entity); + } - public IEnumerable UpdateRange(IEnumerable entities) where TEntity : EasyBaseEntity - { - entities.ToList().ForEach(a => a.ModificationDate = DateTime.UtcNow); - _context.Set().UpdateRange(entities); - return entities; - } + public TEntity Replace(TEntity entity) + where TEntity : class + { + this._context.Entry(entity) + .State = EntityState.Modified; - public async Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : class - { - _context.Set().UpdateRange(entities); - return entities; - } + return entity; + } - public async Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) where TEntity : EasyBaseEntity - { - entities.ToList().ForEach(a => a.ModificationDate = DateTime.UtcNow); - _context.Set().UpdateRange(entities); - return entities; - } + public TEntity Replace(TEntity entity) + where TEntity : EasyBaseEntity + { + entity.ModificationDate = DateTime.UtcNow; + this._context.Entry(entity) + .State = EntityState.Modified; - public IQueryable GetQueryable() where TEntity : class - { - return _context.Set().AsQueryable(); - } + return entity; + } - public IQueryable GetQueryable(Expression> filter) where TEntity : class - { - return _context.Set().Where(filter); - } + public Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class + { + this._context.Entry(entity) + .State = EntityState.Modified; - private IQueryable FindQueryable(bool asNoTracking) where TEntity : class - { - var queryable = GetQueryable(); - if (asNoTracking) - { - queryable = queryable.AsNoTracking(); - } - return queryable; - } + return Task.FromResult(entity); + } - public List GetMultiple(bool asNoTracking) where TEntity : class - { - return FindQueryable(asNoTracking).ToList(); - } + public Task ReplaceAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + entity.ModificationDate = DateTime.UtcNow; + this._context.Entry(entity) + .State = EntityState.Modified; - public async Task> GetMultipleAsync(bool asNoTracking, CancellationToken cancellationToken = default) where TEntity : class - { - return await FindQueryable(asNoTracking).ToListAsync(cancellationToken).ConfigureAwait(false); - } + return Task.FromResult(entity); + } - public List GetMultiple(bool asNoTracking, Expression> projectExpression) where TEntity : class - { - return FindQueryable(asNoTracking).Select(projectExpression).ToList(); - } + public void SoftDelete(TEntity entity) + where TEntity : EasyBaseEntity + { + entity.IsDeleted = true; + entity.DeletionDate = DateTime.UtcNow; + this.Replace(entity); + } - public async Task> GetMultipleAsync(bool asNoTracking, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class - { - return await FindQueryable(asNoTracking).Select(projectExpression).ToListAsync(cancellationToken).ConfigureAwait(false); - } + public void SoftDelete(TPrimaryKey id) + where TEntity : EasyBaseEntity + { + var entity = this._context.Set() + .FirstOrDefault(this.GenerateExpression(id)); + entity.IsDeleted = true; + entity.DeletionDate = DateTime.UtcNow; + this.Replace(entity); + } - public List GetMultiple(bool asNoTracking, Expression> whereExpression) where TEntity : class - { - return FindQueryable(asNoTracking).Where(whereExpression).ToList(); - } + public async Task SoftDeleteAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + entity.IsDeleted = true; + entity.DeletionDate = DateTime.UtcNow; + await this.ReplaceAsync(entity, cancellationToken) + .ConfigureAwait(false); + } - public async Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) where TEntity : class - { - return await FindQueryable(asNoTracking).Where(whereExpression).ToListAsync(cancellationToken).ConfigureAwait(false); - } + public async Task SoftDeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + var entity = await this._context.Set() + .FirstOrDefaultAsync(this.GenerateExpression(id), cancellationToken) + .ConfigureAwait(false); + + entity.IsDeleted = true; + entity.DeletionDate = DateTime.UtcNow; + await this.ReplaceAsync(entity, cancellationToken) + .ConfigureAwait(false); + } - public List GetMultiple(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) where TEntity : class - { - return FindQueryable(asNoTracking).Where(whereExpression).Select(projectExpression).ToList(); - } + public TEntity Update(TEntity entity) + where TEntity : class + { + this._context.Set() + .Update(entity); - public async Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class - { - return await FindQueryable(asNoTracking).Where(whereExpression).Select(projectExpression).ToListAsync(cancellationToken).ConfigureAwait(false); - } + return entity; + } - public List GetMultiple(bool asNoTracking, Func, IIncludableQueryable> includeExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking); - queryable = includeExpression(queryable); - return queryable.ToList(); - } + public TEntity Update(TEntity entity) + where TEntity : EasyBaseEntity + { + entity.ModificationDate = DateTime.UtcNow; + this._context.Set() + .Update(entity); - public async Task> GetMultipleAsync(bool asNoTracking, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking); - queryable = includeExpression(queryable); - return await queryable.ToListAsync(cancellationToken).ConfigureAwait(false); - } + return entity; + } - public List GetMultiple(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return queryable.ToList(); - } + public Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : class + { + this._context.Set() + .Update(entity); - public async Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return await queryable.ToListAsync(cancellationToken).ConfigureAwait(false); - } + return Task.FromResult(entity); + } - public List GetMultiple(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, Expression> projectExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return queryable.Select(projectExpression).ToList(); - } + public Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + entity.ModificationDate = DateTime.UtcNow; + this._context.Set() + .Update(entity); - public async Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return await queryable.Select(projectExpression).ToListAsync(cancellationToken).ConfigureAwait(false); - } + return Task.FromResult(entity); + } - public List GetMultiple(bool asNoTracking, TFilter filter) - where TEntity : class - where TFilter : FilterBase - { - return FindQueryable(asNoTracking).ApplyFilter(filter).ToList(); - } + public IEnumerable UpdateRange(IEnumerable entities) + where TEntity : class + { + this._context.Set() + .UpdateRange(entities); - public async Task> GetMultipleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - return await FindQueryable(asNoTracking).ApplyFilter(filter).ToListAsync(cancellationToken).ConfigureAwait(false); - } + return entities; + } - public List GetMultiple(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return queryable.ToList(); - } + public IEnumerable UpdateRange(IEnumerable entities) + where TEntity : EasyBaseEntity + { + entities.ToList() + .ForEach(a => a.ModificationDate = DateTime.UtcNow); + this._context.Set() + .UpdateRange(entities); - public async Task> GetMultipleAsync(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return await queryable.ToListAsync(cancellationToken).ConfigureAwait(false); - } + return entities; + } - public List GetMultiple(bool asNoTracking, TFilter filter, Expression> projectExpression) - where TEntity : class - where TFilter : FilterBase - { - return FindQueryable(asNoTracking).ApplyFilter(filter).Select(projectExpression).ToList(); - } + /// + public async Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : class + { + this._context.Set() + .UpdateRange(entities); - public async Task> GetMultipleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - return await FindQueryable(asNoTracking).ApplyFilter(filter).Select(projectExpression).ToListAsync(cancellationToken).ConfigureAwait(false); - } + return entities; + } - public List GetMultiple(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return queryable.Select(projectExpression).ToList(); - } - public async Task> GetMultipleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return await queryable.Select(projectExpression).ToListAsync(cancellationToken).ConfigureAwait(false); - } + public async Task> UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default) + where TEntity : EasyBaseEntity + { + entities.ToList() + .ForEach(a => a.ModificationDate = DateTime.UtcNow); + this._context.Set() + .UpdateRange(entities); - public TEntity GetSingle(bool asNoTracking, Expression> whereExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - return queryable.FirstOrDefault(); - } + return entities; + } - public async Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - return await queryable.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); - public TEntity GetSingle(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return queryable.FirstOrDefault(); - } + return await queryable.Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public async Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return await queryable.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + public IQueryable GetQueryable() + where TEntity : class + { + return this._context.Set() + .AsQueryable(); + } - public TProjected GetSingle(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) where TEntity : class - { - return FindQueryable(asNoTracking).Where(whereExpression).Select(projectExpression).FirstOrDefault(); - } + public IQueryable GetQueryable(Expression> filter) + where TEntity : class + { + return this._context.Set() + .Where(filter); + } - public async Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class - { - return await FindQueryable(asNoTracking).Where(whereExpression).Select(projectExpression).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + /// + public async Task GetByIdAsync( + EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); - public TProjected GetSingle(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, Func, IIncludableQueryable> includeExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return queryable.Select(projectExpression).FirstOrDefault(); - } + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } - public async Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, Expression> projectExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(whereExpression); - queryable = includeExpression(queryable); - return await queryable.Select(projectExpression).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .ToList(); + } - public TEntity GetSingle(bool asNoTracking, TFilter filter) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - return queryable.FirstOrDefault(); - } + /// + public List GetMultiple(EfTrackingOptions asNoTracking) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .ToList(); + } - public async Task GetSingleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - return await queryable.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + /// + public List GetMultiple( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); - public TEntity GetSingle(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return queryable.FirstOrDefault(); - } + return queryable.Select(projectExpression) + .ToList(); + } - public async Task GetSingleAsync(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return await queryable.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync(bool asNoTracking, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public TProjected GetSingle(bool asNoTracking, TFilter filter, Expression> projectExpression) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - return queryable.Select(projectExpression).FirstOrDefault(); - } + /// + public async Task> GetMultipleAsync(EfTrackingOptions asNoTracking, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public async Task GetSingleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - return await queryable.Select(projectExpression).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, Expression> projectExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Select(projectExpression) + .ToList(); + } - public TProjected GetSingle(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return queryable.Select(projectExpression).FirstOrDefault(); - } + /// + public List GetMultiple(EfTrackingOptions asNoTracking, Expression> projectExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Select(projectExpression) + .ToList(); + } - public async Task GetSingleAsync(bool asNoTracking, TFilter filter, Expression> projectExpression, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) - where TEntity : class - where TFilter : FilterBase - { - var queryable = FindQueryable(asNoTracking).ApplyFilter(filter); - queryable = includeExpression(queryable); - return await queryable.Select(projectExpression).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync(bool asNoTracking, Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public TEntity GetById(bool asNoTracking, object id) where TEntity : class - { - return _context.Set().FirstOrDefault(GenerateExpression(id)); - } + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public async Task GetByIdAsync(bool asNoTracking, object id, CancellationToken cancellationToken = default) where TEntity : class - { - return await FindQueryable(asNoTracking).FirstOrDefaultAsync(GenerateExpression(id), cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, Expression> whereExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Where(whereExpression) + .ToList(); + } - public TEntity GetById(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(GenerateExpression(id)); - queryable = includeExpression(queryable); - return queryable.FirstOrDefault(); - } + /// + public List GetMultiple(EfTrackingOptions asNoTracking, Expression> whereExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Where(whereExpression) + .ToList(); + } - public async Task GetByIdAsync(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(GenerateExpression(id)); - queryable = includeExpression(queryable); - return await queryable.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Where(whereExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public TProjected GetById(bool asNoTracking, object id, Expression> projectExpression) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(GenerateExpression(id)); - return queryable.Select(projectExpression).FirstOrDefault(); - } + /// + public async Task> GetMultipleAsync(EfTrackingOptions asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Where(whereExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } - public async Task GetByIdAsync(bool asNoTracking, object id, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class - { - var queryable = FindQueryable(asNoTracking).Where(GenerateExpression(id)); - return await queryable.Select(projectExpression).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); - } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .ToList(); + } + + /// + public List GetMultiple(EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking); + queryable = includeExpression(queryable); + + return queryable.ToList(); + } + + /// + public List GetMultiple(EfTrackingOptions asNoTracking, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking); + queryable = includeExpression(queryable); + + return queryable.ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking); + queryable = includeExpression(queryable); + + return await queryable.ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking); + queryable = includeExpression(queryable); + + return await queryable.ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.ToList(); + } + + /// + public List GetMultiple( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .ToList(); + } + + /// + public List GetMultiple( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase + { + return this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .ToList(); + } + + /// + public List GetMultiple(EfTrackingOptions asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase + { + return this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + return await this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync(EfTrackingOptions asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + return await this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.ToList(); + } + + /// + public List GetMultiple(EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return await queryable.ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return await queryable.ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple(bool asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase + { + return this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .Select(projectExpression) + .ToList(); + } + + /// + public List GetMultiple(EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase + { + return this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .Select(projectExpression) + .ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + return await this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task> GetMultipleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + return await this.FindQueryable(asNoTracking) + .ApplyFilter(filter) + .Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public List GetMultiple( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .ToList(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task> GetMultipleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TEntity GetSingle(bool asNoTracking, Expression> whereExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + + return queryable.FirstOrDefault(); + } + + /// + public TEntity GetSingle(EfTrackingOptions asNoTracking, Expression> whereExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + + return queryable.FirstOrDefault(); + } + + /// + public TProjected GetSingle( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TProjected GetSingle( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync(bool asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync(EfTrackingOptions asNoTracking, Expression> whereExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TEntity GetSingle(bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.FirstOrDefault(); + } + + /// + public TEntity GetSingle(EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync( + bool asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TProjected GetSingle(bool asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .FirstOrDefault(); + } + + /// + public TProjected GetSingle(EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression) + where TEntity : class + { + return this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .Where(whereExpression) + .Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TProjected GetSingle( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + /// + public TProjected GetSingle( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync( + bool asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync( + EfTrackingOptions asNoTracking, Expression> whereExpression, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(whereExpression); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TEntity GetSingle(bool asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return queryable.FirstOrDefault(); + } + + /// + public TEntity GetSingle(EfTrackingOptions asNoTracking, TFilter filter) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return queryable.FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync(bool asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync(EfTrackingOptions asNoTracking, TFilter filter, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TEntity GetSingle(bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.FirstOrDefault(); + } + + /// + public TEntity GetSingle(EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return queryable.FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync( + bool asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); - public TProjected GetById(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, Expression> projectExpression) where TEntity : class + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TProjected GetSingle(bool asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + /// + public TProjected GetSingle(EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetSingleAsync( + EfTrackingOptions asNoTracking, TFilter filter, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetSingleAsync( + bool asNoTracking, TFilter filter, Expression> projectExpression, + Func, IIncludableQueryable> includeExpression, CancellationToken cancellationToken = default) + where TEntity : class + where TFilter : FilterBase + { + var queryable = this.FindQueryable(asNoTracking) + .ApplyFilter(filter); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TEntity GetById(bool asNoTracking, object id) + where TEntity : class + { + return this._context.Set() + .FirstOrDefault(this.GenerateExpression(id)); + } + + /// + public TEntity GetById(EfTrackingOptions asNoTracking, object id) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .FirstOrDefault(this.GenerateExpression(id)); + + return queryable; + } + + + /// + public TProjected GetById( + EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetByIdAsync(bool asNoTracking, object id, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .FirstOrDefaultAsync(this.GenerateExpression(id), cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetByIdAsync(EfTrackingOptions asNoTracking, object id, CancellationToken cancellationToken = default) + where TEntity : class + { + return await this.FindQueryable(asNoTracking) + .FirstOrDefaultAsync(this.GenerateExpression(id), cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TEntity GetById(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return queryable.FirstOrDefault(); + } + + /// + public TEntity GetById(EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return queryable.FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetByIdAsync( + bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetByIdAsync( + EfTrackingOptions asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return await queryable.FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TProjected GetById(bool asNoTracking, object id, Expression> projectExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + /// + public TProjected GetById(EfTrackingOptions asNoTracking, object id, Expression> projectExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetByIdAsync( + bool asNoTracking, object id, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + /// + public async Task GetByIdAsync( + EfTrackingOptions asNoTracking, object id, Expression> projectExpression, + CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public TProjected GetById( + bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return queryable.Select(projectExpression) + .FirstOrDefault(); + } + [Obsolete("The boolean option for 'asNoTracking' is obsolete. Please use the Enum.EfTrackingOptions method instead of the boolean version.")] + public async Task GetByIdAsync( + bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, + Expression> projectExpression, CancellationToken cancellationToken = default) + where TEntity : class + { + var queryable = this.FindQueryable(asNoTracking) + .Where(this.GenerateExpression(id)); + queryable = includeExpression(queryable); + + return await queryable.Select(projectExpression) + .FirstOrDefaultAsync(cancellationToken) + .ConfigureAwait(false); + } + + private IQueryable FindQueryable(EfTrackingOptions asNoTracking) + where TEntity : class + { + var queryable = this.GetQueryable(); + if (asNoTracking.HasNoTracking()) { - var queryable = FindQueryable(asNoTracking).Where(GenerateExpression(id)); - queryable = includeExpression(queryable); - return queryable.Select(projectExpression).FirstOrDefault(); + queryable = queryable.AsNoTracking(); } - public async Task GetByIdAsync(bool asNoTracking, object id, Func, IIncludableQueryable> includeExpression, Expression> projectExpression, CancellationToken cancellationToken = default) where TEntity : class + return queryable; + } + + private IQueryable FindQueryable(bool asNoTracking) + where TEntity : class + { + var queryable = this.GetQueryable(); + if (asNoTracking) { - var queryable = FindQueryable(asNoTracking).Where(GenerateExpression(id)); - queryable = includeExpression(queryable); - return await queryable.Select(projectExpression).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); + queryable = queryable.AsNoTracking(); } + + return queryable; + } + + private Expression> GenerateExpression(object id) + { + var type = this._context.Model.FindEntityType(typeof(TEntity)); + var pk = type.FindPrimaryKey() + .Properties.Select(s => s.Name) + .FirstOrDefault(); + var pkType = type.FindPrimaryKey() + .Properties.Select(p => p.ClrType) + .FirstOrDefault(); + + var value = Convert.ChangeType(id, pkType, CultureInfo.InvariantCulture); + + var pe = Expression.Parameter(typeof(TEntity), "entity"); + var me = Expression.Property(pe, pk); + var constant = Expression.Constant(value, pkType); + var body = Expression.Equal(me, constant); + var expression = Expression.Lambda>(body, pe); + + return expression; } -} +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Generic/Startup.cs b/src/EasyRepository.EFCore.Generic/Startup.cs index afab3dd..b192631 100644 --- a/src/EasyRepository.EFCore.Generic/Startup.cs +++ b/src/EasyRepository.EFCore.Generic/Startup.cs @@ -1,50 +1,55 @@ -using EasyRepository.EFCore.Abstractions; +namespace EasyRepository.EFCore.Generic; + +using Abstractions; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -namespace EasyRepository.EFCore.Generic +/// +/// This class includes Service Collection extensions +/// +public static class Startup { /// - /// This class includes Service Collection extensions + /// This method takes service lifetime and database context. + /// In additional this method performs apply easy repository library for own db context /// - public static class Startup + /// + /// database context. + /// + /// + /// Service collection + /// + /// + /// Service LifeTime + /// + /// + /// + /// + public static IServiceCollection ApplyEasyRepository(this IServiceCollection services, ServiceLifetime serviceLifetime = ServiceLifetime.Transient) + where TDbContext : DbContext { - /// - /// This method takes service lifetime and database context. In additional this method performs apply easy repository library for own db context - /// - /// - /// database context. - /// - /// - /// Service collection - /// - /// - /// Service LifeTime - /// - /// - /// - /// - public static IServiceCollection ApplyEasyRepository(this IServiceCollection services, ServiceLifetime serviceLifetime = ServiceLifetime.Transient) where TDbContext : DbContext - { - services.Add(new ServiceDescriptor( + services.Add( + new ServiceDescriptor( typeof(IRepository), serviceProvider => { var dbContext = ActivatorUtilities.CreateInstance(serviceProvider); + return new Repository(dbContext); }, serviceLifetime)); - - services.Add(new ServiceDescriptor( + + services.Add( + new ServiceDescriptor( typeof(IUnitOfWork), serviceProvider => { var repository = serviceProvider.GetService(); + return new UnitOfWork(repository); }, serviceLifetime)); - return services; - } + + return services; } -} +} \ No newline at end of file diff --git a/src/EasyRepository.EFCore.Generic/UnitOfWork.cs b/src/EasyRepository.EFCore.Generic/UnitOfWork.cs index ad84af1..6f3a10b 100644 --- a/src/EasyRepository.EFCore.Generic/UnitOfWork.cs +++ b/src/EasyRepository.EFCore.Generic/UnitOfWork.cs @@ -1,15 +1,16 @@ -using EasyRepository.EFCore.Abstractions; +namespace EasyRepository.EFCore.Generic; -namespace EasyRepository.EFCore.Generic; +using Abstractions; /// -/// Implementation of Unit of work pattern +/// Implementation of Unit of work pattern /// public class UnitOfWork : IUnitOfWork { public UnitOfWork(IRepository repository) { - Repository = repository; + this.Repository = repository; } + public IRepository Repository { get; } } \ No newline at end of file