本文整理汇总了C#中NHibernate.Cfg.Configuration.SetDefaultAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.SetDefaultAssembly方法的具体用法?C# Configuration.SetDefaultAssembly怎么用?C# Configuration.SetDefaultAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.SetDefaultAssembly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareSessionFactory
public void PrepareSessionFactory()
{
Configuration = new Configuration();
Configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
.DataBaseIntegration(db =>
{
db.ConnectionStringName = "db";
db.Dialect<MsSql2008Dialect>();
});
Configuration.SetProperty("show_sql", "true");
Configuration.SetDefaultAssembly("NHibernateDeepDive");
Configuration.SetDefaultNamespace("NHibernate_Deep_Dive.Entities");
Configuration.AddXmlFile("ClearDatabaseScript.hbm.xml");
foreach (var mappingFile in Directory.GetFiles(MappingsDirectory))
{
Configuration.AddXmlFile(mappingFile);
}
AdjustConfiguration(Configuration);
Configuration.SessionFactory().GenerateStatistics();
SessionFactory = Configuration.BuildSessionFactory();
//new SchemaExport(Configuration).Drop(false, true);
new SchemaExport(Configuration).Execute(false, true, false);
BeforeTestRun();
PopulateDatabase();
HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
}
示例2: ExampleApplication
static ExampleApplication()
{
log4net.Config.XmlConfigurator.Configure();
Configuration = new Configuration();
string nhConfigPath = HostingEnvironment.MapPath("~/App_Data/hibernate.cfg.xml");
if (File.Exists(nhConfigPath))
{
Configuration.Configure(nhConfigPath);
}
Configuration.SetDefaultAssembly(typeof(Item).Assembly.FullName)
.SetDefaultNamespace(typeof(Item).Namespace)
.AddDirectory(new DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/")));
SessionFactory = Configuration.BuildSessionFactory();
}
示例3: SetDefaultAssemblyAndNamespace
public void SetDefaultAssemblyAndNamespace()
{
string hbmFromDomainModel =
@"<?xml version='1.0' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
<class name='A'>
<id name='Id' column='somecolumn'>
<generator class='native' />
</id>
</class>
</hibernate-mapping>";
string hbmFromTest =
@"<?xml version='1.0' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
<class name='LocatedInTestAssembly' lazy='false'>
<id name='Id' column='somecolumn'>
<generator class='native' />
</id>
</class>
</hibernate-mapping>";
Configuration cfg = new Configuration();
cfg
.SetDefaultAssembly("NHibernate.DomainModel")
.SetDefaultNamespace("NHibernate.DomainModel")
.AddXmlString(hbmFromDomainModel);
cfg
.SetDefaultAssembly("NHibernate.Test")
.SetDefaultNamespace(typeof(LocatedInTestAssembly).Namespace)
.AddXmlString(hbmFromTest);
cfg.BuildSessionFactory().Close();
}