문제

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".

도움이 되었습니까?

해결책

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<>.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top