public static Configuration Initialize() { INHibernateConfigurationCache cache = new NHibernateConfigurationFileCache(); var mappingAssemblies = new[] { typeof(Customer).Assembly.GetName().Name }; var configuration = cache.LoadConfiguration(CONFIG_CACHE_KEY, null, mappingAssemblies); if (configuration == null) { configuration = new Configuration(); configuration .Proxy(p => p.ProxyFactoryFactory <DefaultProxyFactoryFactory>()) .DataBaseIntegration(db => { db.ConnectionStringName = "MyStoreConnectionString"; db.Dialect <MsSql2008Dialect>(); }) .AddAssembly(typeof(Customer).Assembly) .CurrentSessionContext <LazySessionContext>(); var mapper = new ConventionModelMapper(); mapper.WithConventions(configuration); cache.SaveConfiguration(CONFIG_CACHE_KEY, configuration); } return(configuration); }
public static ISessionFactory BuildSessionFactory(string sessionFactoryKey, string configFile, Assembly mappingAssembly) { var cache = new NHibernateConfigurationFileCache(); var mappingAssemblies = new[] { mappingAssembly.GetName().Name }; var configuration = cache.LoadConfiguration(CONFIG_CACHE_KEY, null, mappingAssemblies, mappingAssembly); if (configuration == null) { configuration = new Configuration(); configuration.Configure(configFile) .CurrentSessionContext <LazySessionContext>(); var mapping = GetMappings(mappingAssembly); configuration.AddMapping(mapping); cache.SaveConfiguration(CONFIG_CACHE_KEY, configuration, mappingAssembly); } var sessionFactory = configuration.BuildSessionFactory(); sessionFactories.Add(sessionFactoryKey, sessionFactory); return(sessionFactory); }
public static Configuration Initialize() { INHibernateConfigurationCache cache = new NHibernateConfigurationFileCache(); var mappingAssemblies = new[] { typeof(Customer).Assembly.GetName().Name }; var configuration = cache.LoadConfiguration(CONFIG_CACHE_KEY, null, mappingAssemblies); if (configuration == null) { configuration = new Configuration(); configuration .Proxy(p => p.ProxyFactoryFactory <DefaultProxyFactoryFactory>()) .DataBaseIntegration(db => { db.ConnectionStringName = "MyStoreConnectionString"; db.Dialect <MsSql2008Dialect>(); }) .AddAssembly(typeof(Customer).Assembly) .CurrentSessionContext <LazySessionContext>(); var mapper = new ConventionModelMapper(); mapper.AddMappings(new List <Type>() { typeof(NhIdentityUserMapping), typeof(NhIdentityUserRoleMapping), typeof(NhNhIdentityUserLoginMapping), typeof(NhIdentityUserClaimMapping) }); var mapping = mapper.CompileMappingFor(new List <Type>() { typeof(NhIdentityUser), typeof(NhIdentityUserRole), typeof(NhIdentityUserLogin), typeof(NhIdentityUserClaim) }); var lastCompiledXml = mapping.AsString(); configuration.AddDeserializedMapping(mapping, "IdentityMappings"); mapper.WithConventions(configuration); cache.SaveConfiguration(CONFIG_CACHE_KEY, configuration); } return(configuration); }
public static Configuration Initialize() { var cache = new NHibernateConfigurationFileCache(); var mappingAssemblies = new[] { typeof(Entity).Assembly.GetName().Name }; var configuration = cache.LoadConfiguration(CONFIG_CACHE_KEY, null, mappingAssemblies); if (configuration == null) { configuration = CreateConfiguration(); var mapper = new ConventionModelMapper(); mapper.WithConventions(configuration); cache.SaveConfiguration(CONFIG_CACHE_KEY, configuration); } return(configuration); }
public static void ResetCache() { var cache = new NHibernateConfigurationFileCache(); cache.Evict(CONFIG_CACHE_KEY); }