Skip to content

Commit

Permalink
fix: generic entity
Browse files Browse the repository at this point in the history
  • Loading branch information
BirajMainali committed Feb 13, 2024
1 parent 247740a commit 255eb65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion App.Base/Repository/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using App.Base.Entities;

namespace App.Base.Repository;

public interface IRepository<T, in TKey> where T : class
public interface IRepository<T, in TKey> where T : FullAuditedEntity<TKey>
{
Task<T?> FindByAsync(TKey id);

Expand Down
4 changes: 3 additions & 1 deletion App.Base/Repository/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using App.Base.Entities;
using Microsoft.EntityFrameworkCore;

namespace App.Base.Repository;

public class Repository<T, TKey> : IRepository<T, TKey> where T : class
public class Repository<T, TKey> : IRepository<T, TKey> where T : FullAuditedEntity<TKey>
{
private readonly DbSet<T> _dbSet;

Expand Down Expand Up @@ -54,6 +55,7 @@ public async Task<T> FindOrThrowAsync(TKey id)
{
throw new KeyNotFoundException($"Entity with key {id} was not found.");
}

return entity;
}
}

0 comments on commit 255eb65

Please sign in to comment.