In my project, I have a base Repository class defined like the following:
internal abstract class Repository<TDomain, TEntity> : IReadWriteRepository<TDomain>
where TDomain : Model
where TEntity : Entity
{
public IQueryable<TDomain> Get()
{
var entities = _context.Set<TEntity>();
return entities.Select(e => _mapper.ToDomain(e));
}
}
As you can see, TEntity has a constraint and must be of type Entity
The Entity class:
public abstract class Entity
{
public int Id { get; set; }
}
And then I have a User class which extends IdentityUser<int>
public class User : IdentityUser<int>, Entity
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
This complains and gives an error that Class 'User' cannot have multiple base classes: 'IdentityUser<int>' and 'Entity'
Since my Repository is constrained to have Entity type I'm wondering how can I get around this?