public class RepositoryModule : NinjectModule
{
public override void Load()
{
/* For demo only...this should be in the web.config. */
const string connectionString = @"Server=localhost; Port=3306; Database=trucktracker; Uid=root; Pwd='your_own_password';";
NHibernateHelper helper = new NHibernateHelper(connectionString);
Bind<ISessionFactory>().ToConstant(helper.SessionFactory)
.InSingletonScope();
Bind<IUnitOfWork>().To<UnitOfWork>()
.InRequestScope();
Bind<ISession>().ToProvider(new SessionProvider())
.InRequestScope();
Bind<IIntKeyedRepository<Truck>>().To<Repository<Truck>>()
.InRequestScope();
}
}
public class SessionProvider : Provider<ISession>
{
protected override ISession CreateInstance(IContext context)
{
UnitOfWork unitOfWork = (UnitOfWork)context.Kernel.Get<IUnitOfWork>();
return unitOfWork.Session;
}
}Thanks. I will give that a try and let you know how it works.
Bob
>--
>You received this message because you are subscribed to the Google Groups
>"ninject" group.
>To post to this group, send email to nin...@googlegroups.com.
>To unsubscribe from this group, send email to
>ninject+u...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/ninject?hl=en.
>