I need to bind a PetaPoco database object with Ninject. In the documentation (https://github.com/CollaboratingPlatypus/PetaPoco/wiki/Fluent-Configuration) the following example is given for SimpleInjector:
var container = new SimpleInjector.Container();
container.RegisterSingleton<IDatabaseBuildConfiguration>(DatabaseConfiguration.Build()
.UsingCommandTimeout(180)
.WithAutoSelect()
.WithNamedParams()
.UsingConnectionStringName("myAppsConnection")
.UsingDefaultMapper<ConventionMapper>(), Lifestyle.Transient);
container.Register<IDatabase>(() => container.GetInstance<IDatabaseBuildConfiguration>().Create())
My other bindings all look like the following.
Bind<IRepRepo>().To<RepRepoWeb>().InSingletonScope();
But I cannot find a clear way how to do this binding in Ninject.
I got it working now. The key is to make use of ToMethod.