From 4e34b047170987e752972a495d4241ae778b68b1 Mon Sep 17 00:00:00 2001 From: Reza Noei Date: Thu, 8 Dec 2022 11:38:12 +0330 Subject: [PATCH] Feature/improvement-on-repositories (#31) * Add extra overload for GetById. * Make GetById method generic. --- Source/BSN.Commons.Orm.EntityFramework/RepositoryBase.cs | 7 +------ .../RepositoryBase.cs | 7 +------ Source/BSN.Commons/Infrastructure/IRepository.cs | 9 +-------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/Source/BSN.Commons.Orm.EntityFramework/RepositoryBase.cs b/Source/BSN.Commons.Orm.EntityFramework/RepositoryBase.cs index fa2a4e6..08819b3 100644 --- a/Source/BSN.Commons.Orm.EntityFramework/RepositoryBase.cs +++ b/Source/BSN.Commons.Orm.EntityFramework/RepositoryBase.cs @@ -129,12 +129,7 @@ public virtual void DeleteRange(IEnumerable entities) dbSet.RemoveRange(entities); } - public virtual T GetById(long id) - { - return dbSet.Find(id); - } - - public virtual T GetById(string id) + public virtual T GetById(KeyType id) { return dbSet.Find(id); } diff --git a/Source/BSN.Commons.Orm.EntityFrameworkCore/RepositoryBase.cs b/Source/BSN.Commons.Orm.EntityFrameworkCore/RepositoryBase.cs index 8d368a8..c7c349b 100644 --- a/Source/BSN.Commons.Orm.EntityFrameworkCore/RepositoryBase.cs +++ b/Source/BSN.Commons.Orm.EntityFrameworkCore/RepositoryBase.cs @@ -40,12 +40,7 @@ public void DeleteRange(IEnumerable entities) dbSet.RemoveRange(entities); } - public virtual T GetById(long id) - { - return dbSet.Find(id); - } - - public virtual T GetById(string id) + public virtual T GetById(KeyType id) { return dbSet.Find(id); } diff --git a/Source/BSN.Commons/Infrastructure/IRepository.cs b/Source/BSN.Commons/Infrastructure/IRepository.cs index e55f085..0c2a8c8 100644 --- a/Source/BSN.Commons/Infrastructure/IRepository.cs +++ b/Source/BSN.Commons/Infrastructure/IRepository.cs @@ -66,14 +66,7 @@ public interface IRepository where T : class /// /// Object Id /// Retrived Object or null - T GetById(long id); - - /// - /// Get Object by id. - /// - /// Object Id - /// Retrived Object or null - T GetById(string id); + T GetById(KeyType id); /// /// Get Object by Expression.