public class SomeRepository<TContext> : IDisposable
where TContext : DbContext, new()
{
protected TContext context;
protected SomeRepository()
{ }
public virtual void Create<T>(T item) where T : class, new()
{
...
}
}
internal class SomeCrud : SomeRepository<SomeContext>
{
public override void Create(Product item)
{
....
}
}
}
I got error on public override void Create(Product item) not suitable method found to override.Please somebody see the mistake?If I’m writing like this:
public override void Create<Product>(Product item)
{
....
}
I can’t see a Product type
Thanks
I think you are looking for this solution:
You actually should define the constraints of the product in the generic definition.
Note the
TinSomeRepository<TContext, T>You can try
but why then use generics?