本文整理汇总了C#中NHibernate.Cfg.Configuration.BuildMapping方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.BuildMapping方法的具体用法?C# Configuration.BuildMapping怎么用?C# Configuration.BuildMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.BuildMapping方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitalizeSessionFactory
public static void InitalizeSessionFactory(params FileInfo[] hbmFiles)
{
if (SessionFactory != null)
return;
var properties = new Dictionary<string, string>
{
{"connection.driver_class", "NHibernate.Driver.SQLite20Driver"},
{"dialect", "NHibernate.Dialect.SQLiteDialect"},
{"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
{"connection.connection_string", "Data Source=askme.db;Version=3;New=True;"},
{"connection.release_mode", "on_close"},
{"show_sql", "true"},
{"proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"}
};
Config = new Configuration {Properties = properties};
foreach (FileInfo mappingFile in hbmFiles)
{
Config = Config.AddFile(mappingFile);
}
Config.BuildMapping();
SessionFactory = Config.BuildSessionFactory();
}
示例2: AppDomainFactory
public static ISessionFactory AppDomainFactory()
{
if (_appDomainFactory == null)
{
lock (_synRoot3)
{
if (_appDomainFactory == null)
{
var createSchema = false;
var configuration = new Configuration()
.DataBaseIntegration(d =>
{
d.ConnectionStringName = Constants.APP_DB;
d.Dialect<MsSql2012Dialect>();
//d.Dialect<Oracle10gDialect>();
d.SchemaAction = SchemaAutoAction.Validate;
})
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.CurrentSessionContext<LazySessionContext>()
.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none")
.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlAuto, (createSchema == true) ? SchemaAutoAction.Update.ToString() : SchemaAutoAction.Validate.ToString());
configuration.AddMapping(GetAppMappings());
configuration.BuildMapping();
if (File.Exists(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY])))
configuration.Configure(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY]));
if (File.Exists(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY_App])))
configuration.Configure(Util.GetFullPath(System.Configuration.ConfigurationManager.AppSettings[Constants.HIBERNATE_CONFIG_KEY_App]));
//new NHibernate.Tool.hbm2ddl.SchemaExport(configuration).SetOutputFile(@"c:\temp\MyDDL.sql").Execute(true /*script*/, true /*export to db*/, false /*just drop*/);
_appDomainFactory = configuration.BuildSessionFactory();
}
}
}
return _appDomainFactory;
}
示例3: InitalizeSessionFactory
public static void InitalizeSessionFactory()
{
if (sessionFactory != null)
return;
var properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver,NHibernate");
properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("connection.connection_string", "Data Source=./../../../database/gringotts.db;Version=3;New=True;");
properties.Add("connection.release_mode", "on_close");
properties.Add("show_sql", "true");
configuration = new Configuration();
configuration.Properties = properties;
configuration.AddAssembly("Gringotts");
configuration.BuildMapping();
sessionFactory = configuration.BuildSessionFactory();
}
示例4: InitalizeSessionFactory
public static void InitalizeSessionFactory(params FileInfo[] hbmFiles)
{
if (sessionFactory != null)
return;
var properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("connection.connection_string", "Data Source=../../../database/getin.db;Version=3");
properties.Add("connection.release_mode", "on_close");
properties.Add("show_sql", "true");
configuration = new Configuration();
configuration.Properties = properties;
foreach (FileInfo mappingFile in hbmFiles)
{
configuration = configuration.AddFile(mappingFile);
}
configuration.BuildMapping();
sessionFactory = configuration.BuildSessionFactory();
}
示例5: InitalizeSessionFactory
public static void InitalizeSessionFactory(params Assembly[] assemblies)
{
if (sessionFactory != null)
return;
var properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("connection.connection_string", "Data Source=:memory:;Version=3;New=True;");
properties.Add("connection.release_mode", "auto");
properties.Add("show_sql", "true");
configuration = new Configuration();
configuration.Properties = properties;
foreach (Assembly assembly in assemblies)
{
configuration = configuration.AddAssembly(assembly);
}
configuration.BuildMapping();
sessionFactory = configuration.BuildSessionFactory();
}