Skip to content

Commit

Permalink
Feature/improvement-on-repositories (#31)
Browse files Browse the repository at this point in the history
* Add extra overload for GetById.

* Make GetById method generic.
  • Loading branch information
Reza-Noei committed Dec 8, 2022
1 parent 1108b26 commit 4e34b04
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
7 changes: 1 addition & 6 deletions Source/BSN.Commons.Orm.EntityFramework/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ public virtual void DeleteRange(IEnumerable<T> 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>(KeyType id)
{
return dbSet.Find(id);
}
Expand Down
7 changes: 1 addition & 6 deletions Source/BSN.Commons.Orm.EntityFrameworkCore/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public void DeleteRange(IEnumerable<T> 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>(KeyType id)
{
return dbSet.Find(id);
}
Expand Down
9 changes: 1 addition & 8 deletions Source/BSN.Commons/Infrastructure/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ public interface IRepository<T> where T : class
/// </summary>
/// <param name="id">Object Id</param>
/// <returns>Retrived Object or null</returns>
T GetById(long id);

/// <summary>
/// Get Object by id.
/// </summary>
/// <param name="id">Object Id</param>
/// <returns>Retrived Object or null</returns>
T GetById(string id);
T GetById<KeyType>(KeyType id);

/// <summary>
/// Get Object by Expression.
Expand Down

0 comments on commit 4e34b04

Please sign in to comment.