views:

79

answers:

1

How I can use multiple parameters in Ninject syntax like following?

Bind<IMyRepository>()
.To<SqlMyRepository>()
.WithConstructorArgument("connectionString",
 ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString
 );

What if more than one parameter need to be passed?

+3  A: 

You can chain the calls to WithConstructorArgument:

Bind<IMyRepository>()
    .To<SqlMyRepository>()
    .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString)
    .WithConstructorArgument("timeout", 10000);
Martin Owen
Thank you, Martin. +1
rem