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