Вопрос

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