I am having a generic interface as:
public IRepository< T >
{
void Add(T entity);
}
and a class as:
public class Repository< T >:IRepository< T >
{
void Add(T entity)
{ //Some Implementation
}
}
Now I want to make an extension method of the above interface. I made the following class:
public static class RepositoryExtension
{
public static void Add(this IRepository< T > dataAccessRepository, T entity, string additionalValue)
{
//Some Implementation
}
}
But I get error in the extension Add method. It doesn't recognize the Type 'T' I have passed to IRepository. I cannot event pass this Type to my Extenstion Methods class i.e RepositoryExtension< T >. Please guide the appropriate way.
public static void Add<T>(this IRepository< T > dataAccessRepository, T entity, string additionalValue)
Try that.
Notice the <T>
immediately after the Add
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With