public override void Initialize() { var connStrNames = new List <string> { "Shard1", "Shard2", "Shard3" }; var shardConfigs = connStrNames.Select((x, index) => new ShardConfiguration { ShardId = (short)index, ConnectionStringName = x }); var protoConfig = new Configuration() .DataBaseIntegration( x => { x.Dialect <MsSql2012Dialect>(); x.Driver <Sql2008ClientDriver>(); }) .AddResource("QueryRecipes.Sharding.ShardedProduct.hbm.xml", GetType().Assembly); var shardedConfig = new ShardedConfiguration(protoConfig, shardConfigs, new ShardStrategyFactory()); CreateSchema(shardedConfig); try { _sessionFactory = shardedConfig.BuildShardedSessionFactory(); } catch { DropSchema(shardedConfig); throw; } }
public void TestFixtureSetUp() { var currentAssembly = GetType().Assembly; var protoConfig = new Configuration() .SetDefaultAssembly(currentAssembly.FullName) .SetProperty(Environment.ConnectionDriver, typeof(MilestoneTG.NHibernate.Driver.Sqlite.Microsoft.MicrosoftSqliteDriver).AssemblyQualifiedName) .SetProperty(Environment.Dialect, typeof(NHibernate.Dialect.SQLiteDialect).FullName) .SetProperty(Environment.QuerySubstitutions, "true=1;false=0") .AddAssembly(currentAssembly); try { Configure(protoConfig); var shardedConfig = new ShardedConfiguration(protoConfig, CreateShardConfigurations(2), new TestStrategyFactory()); CreateSchema(shardedConfig); try { _sessionFactory = shardedConfig.BuildShardedSessionFactory(); } catch { DropSchema(shardedConfig); throw; } } catch (Exception) { CleanUp(); throw; } }
private void CleanUp() { if (_sessionFactory != null) { _sessionFactory.Close(); _sessionFactory = null; } foreach (var databasePath in _databasePaths) { if (File.Exists(databasePath)) { File.Delete(databasePath); } } }
public void TestFixtureSetUp() { var currentAssembly = GetType().Assembly; var protoConfig = new Configuration() .SetDefaultAssembly(currentAssembly.FullName) .SetProperty(Environment.ConnectionDriver, typeof(NHibernate.Driver.SQLite20Driver).FullName) .SetProperty(Environment.Dialect, typeof(NHibernate.Dialect.SQLiteDialect).FullName) .SetProperty(Environment.QuerySubstitutions, "true=1;false=0") .AddAssembly(currentAssembly); try { Configure(protoConfig); var shardedConfig = new ShardedConfiguration(protoConfig, CreateShardConfigurations(2), new TestStrategyFactory()); CreateSchema(shardedConfig); try { _sessionFactory = shardedConfig.BuildShardedSessionFactory(); } catch { DropSchema(shardedConfig); throw; } } catch (Exception) { CleanUp(); throw; } }
private void CleanUp() { if (_sessionFactory != null) { _sessionFactory.Close(); _sessionFactory = null; } foreach (var databasePath in _databasePaths) { if (File.Exists(databasePath)) File.Delete(databasePath); } }