I have a generic repository for my crud in netcore, but I have a problem with one of the methods.
The method is GetById
public async Task<TEntity> GetById(int id)
{
return await _dbContext.Set<TEntity>()
.AsNoTracking()
.FirstOrDefault(t => t.Id == id);
}
And in the% share% of%
There is an error
'TEntity' does not contain a definition for 'Id' nor is there any Extension method 'Id' that accepts a first argument of type 'TEntity' (missing any using directive or a reference from assembled?)
This would be the header of my GenericRepository
public class GenericRepository<TEntity> : IGenericRepository<TEntity>
where TEntity : class
{
private readonly DataContext _dbContext;
public GenericRepository(DataContext dbContext)
{
_dbContext = dbContext;
}