From e5eeef589fa90d5e605617dcf11be91cfa9b39c5 Mon Sep 17 00:00:00 2001 From: transtrike Date: Tue, 8 Dec 2020 21:00:32 +0200 Subject: Move Interfaces in Models project --- API/Database/DbRepository.cs | 3 ++- API/Database/Interfaces/IRepository.cs | 24 ------------------------ Models/Interfaces/Database/IRepository.cs | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 API/Database/Interfaces/IRepository.cs create mode 100644 Models/Interfaces/Database/IRepository.cs diff --git a/API/Database/DbRepository.cs b/API/Database/DbRepository.cs index 5540104..b961a54 100644 --- a/API/Database/DbRepository.cs +++ b/API/Database/DbRepository.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Camera_Shop.Database; +using Models.Interfaces.Database; using Microsoft.EntityFrameworkCore; namespace API.Database @@ -37,6 +37,7 @@ namespace API.Database { return this._context .Set() + .AsNoTracking() .Take(count) .AsAsyncEnumerable(); } diff --git a/API/Database/Interfaces/IRepository.cs b/API/Database/Interfaces/IRepository.cs deleted file mode 100644 index 927e006..0000000 --- a/API/Database/Interfaces/IRepository.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Camera_Shop.Database -{ - public interface IRepository - where TEntity : class - { - //Add Entity to database - Task AddAsync(TEntity entity); - - //Return *count* instances of Entity from the database - Task> Query(int count); - - //Find entity by id - Task FindByIdAsync(object id); - - //Modify Entity from database - Task EditAsync(object id, TEntity newEntity); - - //Delete Entity from database - Task DeleteAsync(object id); - } -} \ No newline at end of file diff --git a/Models/Interfaces/Database/IRepository.cs b/Models/Interfaces/Database/IRepository.cs new file mode 100644 index 0000000..e38bb82 --- /dev/null +++ b/Models/Interfaces/Database/IRepository.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Models.Interfaces.Database +{ + public interface IRepository + where TEntity : class + { + //Add Entity to database + Task AddAsync(TEntity entity); + + //Return *count* instances of Entity from the database + Task> Query(int count); + + //Find entity by id + Task FindByIdAsync(object id); + + //Modify Entity from database + Task EditAsync(object id, TEntity newEntity); + + //Delete Entity from database + Task DeleteAsync(object id); + } +} \ No newline at end of file -- cgit v1.2.3