Пример #1
0
        //
        // GET: /Install/

        public ActionResult Step1()
        {
            var SchemaExport = new NHibernate.Tool.hbm2ddl.SchemaExport(RegisterNHibernate.Configure());

            SchemaExport.Drop(false, true);
            SchemaExport.Create(false, true);

            var site = new Site {
                Name = "vbgCMS"
            };
            var session = ServiceLocator.Current.GetInstance <ISession>();

            using (var transaction = session.BeginTransaction())
            {
                try
                {
                    session.Save(site);
                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }

            return(RedirectToAction("Completed"));
        }
Пример #2
0
 public NHibernateRegistry()
 {
     ForRequestedType <ISessionFactory>().CacheBy(InstanceScope.HttpContext).TheDefault.Is.ConstructedBy(ctx =>
                                                                                                         RegisterNHibernate.Configure().BuildSessionFactory());
     ForRequestedType <ISession>().CacheBy(InstanceScope.HttpContext).TheDefault.Is.ConstructedBy(ctx => ctx.GetInstance <ISessionFactory>().GetCurrentSession() /*  CustomSessionContext.CurrentSession */);
 }