Kyrylo Bezpalyi
Kyrylo Bezpalyi

Reputation: 43

Ninject binding with two generic parameters in types

I have this interface:

public interface IRepository<TDomain, TBusiness>
    where TDomain : class
    where TBusiness : class
    {...}

And this class:

public class Repository<TDomain, TBusiness> : IRepository<TDomain,    TBusiness>
    where TDomain : class
    where TBusiness : class
    {...}

And when i bind in with ninject, something like:

Kernel.Bind(typeof(IRepository<>))
      .To(typeof(Repository<>))
      .InRequestScope();

And have an error "Incorrect number of type parameters in ...". When I have only one generic in type everything works fine. Have anyone solution to fix this problem?

Upvotes: 1

Views: 427

Answers (1)

Steven
Steven

Reputation: 172646

This has nothing to do with Ninject, the error you are getting is a C# compiler error. That's because the correct way to specify a type with two generic arguments is the following:

typeof(IRepository<,>)

Upvotes: 1

Related Questions