Ninject : Constructor parameter

后端 未结 2 1542
抹茶落季
抹茶落季 2021-01-01 03:45

I am using Ninject together with ASP.NET MVC 4. I am using repositories and want to do constructor injection to pass in the repository to one of the controllers.

Thi

2条回答
  •  独厮守ぢ
    2021-01-01 04:00

    I'd use the WithConstructorArgument() method like...

    Bind>().To>()
        .WithConstructorArgument("tableName", "categories");
    

    The rest of the repository design is probably another question. IMHO It seems like a big no no to create a table or do any heavy lifting in a ctor.

提交回复
热议问题