本文整理汇总了C#中NHibernate.Cfg.Configuration.BuildMappings方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.BuildMappings方法的具体用法?C# Configuration.BuildMappings怎么用?C# Configuration.BuildMappings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.BuildMappings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public static void Configure(string pathToConfig, Assembly mappingsAssembly)
{
_cfg = new Configuration();
_cfg.Configure(pathToConfig);
_cfg.AddAssembly(mappingsAssembly);
_cfg.BuildMappings();
_sessionFactory = _cfg.BuildSessionFactory();
}
示例2: NwaitingForSuper
public void NwaitingForSuper()
{
Configuration cfg = new Configuration();
cfg.AddResource(BaseForMappings + "Extendshbm.Customer.hbm.xml", typeof (ExtendsFixture).Assembly);
Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Null, "cannot be in the configuration yet!");
cfg.AddResource(BaseForMappings + "Extendshbm.Employee.hbm.xml", typeof (ExtendsFixture).Assembly);
Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Null, "cannot be in the configuration yet!");
cfg.AddResource(BaseForMappings + "Extendshbm.Person.hbm.xml", typeof (ExtendsFixture).Assembly);
cfg.BuildMappings();
Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
Assert.That(cfg.GetClassMapping(typeof (Person).FullName), Is.Not.Null);
Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Not.Null);
}
示例3: SetUp
public void SetUp()
{
cfg = new Configuration()
.AddResource("NHibernate.Test.MappingTest.Wicked.hbm.xml", GetType().Assembly);
cfg.BuildMappings();
}
示例4: JoinedSubclassAndEntityNamesOnly
public void JoinedSubclassAndEntityNamesOnly()
{
Configuration cfg = new Configuration();
cfg.AddResource(BaseForMappings + "Extendshbm.entitynames.hbm.xml", typeof (ExtendsFixture).Assembly);
cfg.BuildMappings();
Assert.That(cfg.GetClassMapping("EntityHasName"), Is.Not.Null);
Assert.That(cfg.GetClassMapping("EntityCompany"), Is.Not.Null);
}
示例5: UnionSubclass
public void UnionSubclass()
{
Configuration cfg = new Configuration();
cfg.AddResource(BaseForMappings + "Extendshbm.unionsubclass.hbm.xml", typeof (ExtendsFixture).Assembly);
cfg.BuildMappings();
Assert.That(cfg.GetClassMapping(typeof (Person).FullName), Is.Not.Null);
Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
}
示例6: EntityNamesWithPackageFailureExpectedDiffFiles
public void EntityNamesWithPackageFailureExpectedDiffFiles()
{
Configuration cfg = new Configuration();
cfg.AddResource(BaseForMappings + "Extendshbm.packageentitynamesf1.hbm.xml", typeof(ExtendsFixture).Assembly);
cfg.AddResource(BaseForMappings + "Extendshbm.packageentitynamesf2.hbm.xml", typeof(ExtendsFixture).Assembly);
cfg.BuildMappings();
Assert.That(cfg.GetClassMapping("EntityHasName"), Is.Not.Null);
Assert.That(cfg.GetClassMapping("EntityCompany"), Is.Not.Null);
}
示例7: Configure
private static void Configure(Configuration config)
{
config.BuildMappings();
new SchemaUpdate(config).Execute(false, true);
}
示例8: ConfigureNHibernate
private void ConfigureNHibernate()
{
_configuration = new Configuration();
_configuration.DataBaseIntegration(x =>
{
if (_inMemory)
{
x.Dialect<SQLiteDialect>();
x.Driver<SQLite20Driver>();
x.ConnectionProvider<DriverConnectionProvider>();
}
else
x.Dialect<MsSql2008Dialect>();
x.ConnectionString = _connectionString;
x.SchemaAction = SchemaAutoAction.Update;
x.IsolationLevel = IsolationLevel.ReadCommitted;
x.HqlToSqlSubstitutions = "True 1, False 0, true 1, false 0, yes 'Y', no 'N'";
x.BatchSize = 200;
});
var mappingAssemblies = _assemblies;
foreach (var mappingAssembly in mappingAssemblies.Where(mappingAssembly => !String.IsNullOrWhiteSpace(mappingAssembly)))
{
_configuration.AddAssembly(mappingAssembly);
}
_configuration.BuildMappings();
_configuration.SetProperty(NHEnvironment.CacheDefaultExpiration, 120.ToString());
_configuration.SetProperty(NHEnvironment.ShowSql, "false");
_configuration.Proxy(cfg => cfg.ProxyFactoryFactory<DefaultProxyFactoryFactory>());
_configuration.SessionFactory()
.GenerateStatistics();
}
示例9: ConfigureNHibernate
/// <summary>
/// Configure NHibernate
/// </summary>
private void ConfigureNHibernate()
{
_configuration = new NHConfiguration();
_configuration.DataBaseIntegration(x =>
{
//x.AutoCommentSql = true;
//x.Dialect<MsSqlCustomDialect>();
x.Dialect<MsSqlCustomDialect>();
x.ConnectionString = _connectionString;
x.SchemaAction = SchemaAutoAction.Update;
x.IsolationLevel = IsolationLevel.ReadCommitted;
x.HqlToSqlSubstitutions = "True 1, False 0, true 1, false 0, yes 'Y', no 'N'";
x.BatchSize = 15;
});
var mappingAssemblies = _assemblies;
foreach (var mappingAssembly in mappingAssemblies)
{
if (!String.IsNullOrWhiteSpace(mappingAssembly))
{
_configuration.AddAssembly(mappingAssembly);
}
}
_configuration.BuildMappings();
_configuration.Cache(cfg =>
{
cfg.DefaultExpiration = 120;
cfg.Provider<SysCacheProvider>();
cfg.UseMinimalPuts = true;
cfg.RegionsPrefix = "xyz";
cfg.UseQueryCache = true;
});
_configuration.SetProperty(NHibernate.Cfg.Environment.CacheDefaultExpiration, 120.ToString());
_configuration.SetProperty(NHibernate.Cfg.Environment.ShowSql, "false");
_configuration.Proxy(cfg => cfg.ProxyFactoryFactory<DefaultProxyFactoryFactory>());
_configuration.SessionFactory()
.GenerateStatistics();
new AuditingEventListener().Register(_configuration);
}