예제 #1
0
        private static ISessionFactory BuildNHibernateSessionFacotory()
        {
            var typesThatShouldBeMapped = Assembly.GetAssembly(typeof(Entity)).GetExportedTypes().Where(t => t.Namespace.EndsWith("DTOs"));
            var cfg = new NHibernate.Cfg.Configuration();
            cfg.Properties[NHibernate.Cfg.Environment.CollectionTypeFactoryClass] = typeof(Sharetronix.Cfg.ForNHibernate.Net4CollectionTypeFactory).AssemblyQualifiedName;
            cfg = cfg.AddAutoMappings(typesThatShouldBeMapped, customClassMappings);

            if (isNewInstance)
                cfg.CreateDatabaseTables();

            return cfg.BuildSessionFactory();
        }