Matthew North
Matthew North

Reputation: 555

Interface with generic type used as generic type within second interface

I have an interface that references accepts generic type:

public interface IEntity<TType>

I hope to pass a reference of this to a second interface that takes a generic type:

public interface IRepository<T> : IDisposable where T : IEntity, new()

I have tried getting this to work but have so far failed to have it build.

Is there any way this can be done?

Upvotes: 2

Views: 51

Answers (1)

JLRishe
JLRishe

Reputation: 101682

Your interface is IEntity<T>, not IEntity. This means that the signature of your IRepository needs to reflect this:

public interface IEntity<TType>

public interface IRepository<T, TEntity> : IDisposable where T : IEntity<TEntity>, new()

Upvotes: 5

Related Questions