I am building a entity Repository and I have an interface, IIdentifiable<T>
. So entities which are identified by Guids, for example, implement IIdentifiable<Guid> with public Guid Id { get; }
. So far, so good.
I have an interface of IRepository<T, TIdentifier> where T : IIdentifiable<TIdentifier>
.
It seems to me that the TIdentifier generic argument is redundant, because that already information is held in the generic argument of T. Is there any way I can have a cleaner implementation of IRepository, where I only have to specify T in my business code?
I'm after something like 'IRepository<T> where T : IIdentifiable<T.GenericArgs[0]>
.
I doubt this is possible, but just thought I'd ask. Maybe the new C# 4 stuff has something for this this?