public void Setup() { var mapper = new ModelMapper(); mapper.AddMapping <OutboxEntityMap>(); var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary <string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString, connectionString } }); configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); new SchemaUpdate(configuration).Execute(false, true); SessionFactory = configuration.BuildSessionFactory(); Session = SessionFactory.OpenSession(); persister = new OutboxPersister { StorageSessionProvider = new FakeSessionProvider(SessionFactory, Session), EndpointName = "TestEndpoint" }; }
public void Setup() { var mapper = new ModelMapper(); mapper.AddMapping<OutboxEntityMap>(); var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary<string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString,connectionString } }); configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); new SchemaUpdate(configuration).Execute(false, true); SessionFactory = configuration.BuildSessionFactory(); Session = SessionFactory.OpenSession(); persister = new OutboxPersister { StorageSessionProvider = new FakeSessionProvider(SessionFactory, Session), EndpointName = "TestEndpoint" }; }
public void SetUp() { connectionString = String.Format(@"Data Source={0};New=True;", Path.GetTempFileName()); var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary <string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString, connectionString } }); var modelMapper = new SagaModelMapper(new[] { typeof(T) }); configuration.AddMapping(modelMapper.Compile()); SessionFactory = configuration.BuildSessionFactory(); new SchemaUpdate(configuration).Execute(false, true); session = SessionFactory.OpenSession(); SagaPersister = new SagaPersister(new FakeSessionProvider(SessionFactory, session)); new Installer().Install(WindowsIdentity.GetCurrent().Name, null); }
/// <summary> /// Builds the session factory with the given properties. Database is updated if updateSchema is set /// </summary> public ISessionFactory Build(Configuration nhibernateConfiguration) { var scannedAssemblies = typesToScan.Select(t => t.Assembly).Distinct(); foreach (var assembly in scannedAssemblies) { nhibernateConfiguration.AddAssembly(assembly); } var modelMapper = new SagaModelMapper(typesToScan.Except(nhibernateConfiguration.ClassMappings.Select(x => x.MappedClass))); nhibernateConfiguration.AddMapping(modelMapper.Compile()); try { return(nhibernateConfiguration.BuildSessionFactory()); } catch (Exception e) { if (e.InnerException != null) { throw new ConfigurationErrorsException(e.InnerException.Message, e); } throw; } }
public void SetUp() { ConnectionString = $@"Data Source={Path.GetTempFileName()};New=True;"; var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary <string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString, ConnectionString } }); var metaModel = new SagaMetadataCollection(); metaModel.Initialize(new[] { typeof(T) }); var metadata = metaModel.Find(typeof(T)); var modelMapper = new SagaModelMapper(metaModel, new[] { metadata.SagaEntityType }); configuration.AddMapping(modelMapper.Compile()); SessionFactory = configuration.BuildSessionFactory(); new SchemaUpdate(configuration).Execute(false, true); SagaPersister = new SagaPersister(); }
/// <summary> /// Builds the session factory with the given properties. Database is updated if updateSchema is set /// </summary> public ISessionFactory Build(Configuration nhibernateConfiguration) { var scannedAssemblies = typesToScan.Select(t => t.Assembly).Distinct(); foreach (var assembly in scannedAssemblies) { nhibernateConfiguration.AddAssembly(assembly); } var modelMapper = new SagaModelMapper(typesToScan.Except(nhibernateConfiguration.ClassMappings.Select(x => x.MappedClass))); nhibernateConfiguration.AddMapping(modelMapper.Compile()); try { return nhibernateConfiguration.BuildSessionFactory(); } catch (Exception e) { if (e.InnerException != null) throw new ConfigurationErrorsException(e.InnerException.Message, e); throw; } }
public void Setup() { var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary <string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString, connectionString } }); var mapper = new ModelMapper(); mapper.AddMapping <TimeoutEntityMap>(); configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); new SchemaExport(configuration).Create(false, true); sessionFactory = configuration.BuildSessionFactory(); persister = new TimeoutPersister { SessionFactory = sessionFactory, DbConnectionProvider = new FakeDbConnectionProvider(sessionFactory.GetConnection()), EndpointName = "MyTestEndpoint" }; }
private static ISessionFactory ByCodeMapped(INHibernateCodeConfig nhibernateConfiguration, Assembly assembly) { var mapper = new ModelMapper(); mapper.AddMappings(assembly.GetExportedTypes() .Where(t => t.BaseType != null && t.BaseType.IsGenericType && t.BaseType.GetGenericTypeDefinition() == typeof(ClassMapping <>))); var configure = new global::NHibernate.Cfg.Configuration(); nhibernateConfiguration.AddDataBaseIntegrationInfo(configure); configure.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); return(configure.BuildSessionFactory()); }
public void Setup() { var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary <string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString, connectionString } }); var mapper = new ModelMapper(); mapper.AddMapping <TimeoutEntityMap>(); configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); new SchemaExport(configuration).Create(false, true); sessionFactory = configuration.BuildSessionFactory(); persister = new TimeoutPersister("MyTestEndpoint", sessionFactory, new NHibernateSynchronizedStorageAdapter(sessionFactory), new NHibernateSynchronizedStorage(sessionFactory), TimeSpan.FromMinutes(2)); }
public static ISessionFactory GetSessionFactory(HibernateDataContext cotnext) { var cfg = new global::NHibernate.Cfg.Configuration(); cfg.DataBaseIntegration(c => { c.ConnectionStringName = cotnext.ConnectionString; if (cotnext.Provider != null && cotnext.Provider.Equals("System.Data.SqlServerCe.4.0", StringComparison.OrdinalIgnoreCase)) { c.Driver <SqlServerCeDriver>(); c.Dialect <MsSqlCe40Dialect>(); } else { c.Driver <SqlClientDriver>(); c.Dialect <MsSql2008Dialect>(); } #if DEBUG c.LogFormattedSql = true; #endif c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote; c.SchemaAction = SchemaAutoAction.Update; }); var mapper = new ModelMapper(); MapModels(mapper, cotnext.DbContext); cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); var result = cfg.BuildSessionFactory(); if (cotnext.BuildSchema) { BuildSchema(cfg); } if (cotnext.UpdateSchema) { UpdateSchema(cfg); } return(result); }
internal ISessionFactory CreateSessionFactory() { var cfg = new global::NHibernate.Cfg.Configuration().DataBaseIntegration(x => { x.ConnectionString = connectionString; x.Driver <OracleManagedDataClientDriver>(); x.Dialect <Oracle10gDialect>(); x.LogSqlInConsole = true; }); var mapper = new ModelMapper(); mapper.AddMapping <TimeoutEntityMap>(); mapper.AddMapping <StagedTimeoutEntityMap>(); HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); cfg.AddMapping(mapping); cfg.SetProperty("hbm2ddl.auto", "update"); // creates the schema, destroying previous data return(cfg.BuildSessionFactory()); }
public void Setup() { var configuration = new global::NHibernate.Cfg.Configuration() .AddProperties(new Dictionary<string, string> { { "dialect", dialect }, { global::NHibernate.Cfg.Environment.ConnectionString, connectionString } }); var mapper = new ModelMapper(); mapper.AddMapping<TimeoutEntityMap>(); configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); new SchemaExport(configuration).Create(false, true); sessionFactory = configuration.BuildSessionFactory(); persister = new TimeoutPersister { SessionFactory = sessionFactory, DbConnectionProvider = new FakeDbConnectionProvider(sessionFactory.GetConnection()), EndpointName = "MyTestEndpoint" }; }