Question

I have a generic interface defined like this -

public interface IGenericRepository<TEntity, TDbContextType>
    where TEntity : class
    where TDbContextType : IDbContextType 

This interface is implemented by a class like this -

 public class GenericRepository<TEntity,TDbContextType> 
    : IGenericRepository<TEntity, TDbContextType> 
    where TEntity : class 
    where TDbContextType: IDbContextType

I tried the following for registering this interface and implementation with castle -

   _container.Register(Component.For(typeof (IGenericRepository<>))
       .ImplementedBy(typeof (GenericRepository<>))
       .LifestylePerWcfOperation());

But it fails at compile time Saying "incorrect number of paramters".

Was it helpful?

Solution

It fails to compile because you specific generic types with one single parameter, but you defined types with two parameters.

So you should use IGenericRepository<,> and GenericRepository<,> instead of IGenericRepository<> and GenericRepository<>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top