1

I'm using Ninject DI container. And I've got the two

public interface IRepository<T> where T : AbstractEntity<T>, IAggregateRoot
{ 
    // methods signatures
}

public class Repository<T> : IRepository<T> where T : AbstractEntity<T>, IAggregateRoot
{
    // implementations
} 

Then I'm trying to bind them in a separate module

public class DataAccessModule : Ninject.Modules.NinjectModule
{
    public override void Load()
    {
        this.Bind<IRepository<>>().To<Repository<>>();
    }
}

where this.Bind<IRepository<>>().To<Repository<>>(); is not recognized as a statement.

How do I make a bind?

lexeme
  • 2,915
  • 10
  • 60
  • 125
  • possible duplicate of [NInject with Generic interface](http://stackoverflow.com/questions/2216127/ninject-with-generic-interface) – nawfal Nov 05 '13 at 04:47

1 Answers1

5

Snagged this piece from here. Looks like it worked for them:

Bind(typeof(IRepository<>)).To(typeof(Repository<>));
Community
  • 1
  • 1
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184