我有一个像这样定义的通用接口 -
public interface IGenericRepository<TEntity, TDbContextType>
where TEntity : class
where TDbContextType : IDbContextType
此接口由类似这样的类实现 -
public class GenericRepository<TEntity,TDbContextType>
: IGenericRepository<TEntity, TDbContextType>
where TEntity : class
where TDbContextType: IDbContextType
我尝试了以下注册这个接口和实现与城堡 -
_container.Register(Component.For(typeof (IGenericRepository<>))
.ImplementedBy(typeof (GenericRepository<>))
.LifestylePerWcfOperation());
但它在编译时失败说“参数数量不正确”。
答案 0 :(得分:3)
它无法编译,因为您使用一个参数的特定泛型类型,但您使用两个参数定义了类型。
因此,您应该使用IGenericRepository<,>
和GenericRepository<,>
代替IGenericRepository<>
和GenericRepository<>
。