protected override void Load(ContainerBuilder builder)
 {
     base.Load(builder);
     var nhConfiguration = new NHibernateConfiguration(ConnectionString);
     builder.Register(c => nhConfiguration.GetSessionFactory()).As<ISessionFactory>().SingleInstance();
     builder.Register(c => c.Resolve<ISessionFactory>().OpenSession()).As<ISession>().InstancePerHttpRequest();
 }
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);
            var nhConfiguration = new NHibernateConfiguration(ConnectionString);

            builder.Register(c => nhConfiguration.GetSessionFactory()).As <ISessionFactory>().SingleInstance();
            builder.Register(c => c.Resolve <ISessionFactory>().OpenSession()).As <ISession>().InstancePerHttpRequest();
        }
예제 #3
0
        public void FixtureSetup()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["GlossaryDataSource"].ConnectionString;
            using (IAnnouncer announcer = new TextWriterAnnouncer(Console.Out))
            {
                IRunnerContext migrationContext = new RunnerContext(announcer)
                {
                    Connection = connectionString,
                    Database = "SqlServer2008",
                    Target = Assembly.GetAssembly(typeof(NHibernateConfiguration)).FullName
                };

                new TaskExecutor(migrationContext).Execute();
            }

            var nhConfiguration = new NHibernateConfiguration(connectionString);
            _sessionFactory = nhConfiguration.GetSessionFactory();
            _session = _sessionFactory.OpenSession();
            _repository = new GlossaryRepository(_sessionFactory.OpenSession());
        }