本文整理匯總了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();
}