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 IConfigurationProvider CreateConfigurationProvider() { var configFilePath = PathHelpers.InCurrentAppDomain(Constants.NHibernateConfigFileName); var configuration = new Configuration(); configuration.Configure(configFilePath); var mapper = new ConventionModelMapper(); mapper.WithConventions(); mapper.WithMappings(configuration); return(new ConfigurationProvider(configuration)); }
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 void CanGenerateMappingDoc() { // Need a separate config so we can get hold of the mapper after using it. // If we use the existing config we get a duplicate mapping exception. var config = NHibernateInitializer.CreateConfiguration(); var mapper = new ConventionModelMapper(); mapper.WithConventions(config); var mapping = mapper.CompileMappingFor(typeof(Entity).Assembly.GetExportedTypes()); var x = mapping.AsString(); File.WriteAllText("../../NHibernateTests/Output.xml", x); }
public static Configuration Initialize() { Configuration configuration = new Configuration(); configuration .Proxy(p => p.ProxyFactoryFactory <DefaultProxyFactoryFactory>()) .DataBaseIntegration(db => { db.ConnectionStringName = "CaTSConnectionString"; db.Dialect <MsSql2008Dialect>(); }) .AddAssembly(typeof(ActionConfirmation <>).Assembly) .CurrentSessionContext <LazySessionContext>(); ConventionModelMapper mapper = new ConventionModelMapper(); mapper.WithConventions(configuration); return(configuration); }
public static Configuration Initialize() { var configuration = new Configuration(); configuration .Proxy(p => p.ProxyFactoryFactory <DefaultProxyFactoryFactory>()) .DataBaseIntegration(db => { db.ConnectionStringName = "DevelopmentStack"; db.Dialect <MsSql2008Dialect>(); db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote; }) .AddAssembly(typeof(Stack).Assembly) .CurrentSessionContext <LazySessionContext>(); ConventionModelMapper mapper = new ConventionModelMapper(); mapper.WithConventions(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); }