本文整理汇总了C#中NHibernate.Cfg.Configuration.AddDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddDirectory方法的具体用法?C# Configuration.AddDirectory怎么用?C# Configuration.AddDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.AddDirectory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NHibernateManager
static NHibernateManager()
{
Configuration cfg= new Configuration().Configure();
//cfg.AddAssembly("App_SubCode_APAS");
//cfg.AddClass(typeof(Apas.Business.BCOtherFeeType));
//Business Persistent Entity Mappings
cfg.AddDirectory(new System.IO.DirectoryInfo
(
HttpContext.Current.Server.MapPath
(
@"~/App_Code/APAS/Business/NHibernate Mappings/"
)
)
);
//Security Layer Entity Mappings
cfg.AddDirectory(new System.IO.DirectoryInfo
(
HttpContext.Current.Server.MapPath
(
@"~/App_Code/APAS/Security/NHibernate Mappings/"
)
)
);
sessionFactory= cfg.BuildSessionFactory();
}
示例2: Main
static void Main()
{
DbConnectionStringBuilder dcsBuilder = new DbConnectionStringBuilder();
dcsBuilder.Add("User ID", "wjzgis");
dcsBuilder.Add("Password", "wjzgis");
dcsBuilder.Add("Service Name", "sunz");
dcsBuilder.Add("Host", "172.16.1.9");
dcsBuilder.Add("Integrated Security", false);
string licPath = Application.StartupPath + "\\DDTek.lic";
//dcsBuilder.Add("License Path", licPath);
//若路径中存在空格,则会在路径名称前加上"\""
string conStr = dcsBuilder.ConnectionString;
conStr = conStr.Replace("\"", "");
Configuration config = new Configuration();
config.AddDirectory(new System.IO.DirectoryInfo( System.IO.Path.Combine(Application.StartupPath, "DataMapping")));
config.Properties["connection.connection_string"] = conStr;
NHibernate.ISessionFactory sFactory = config.BuildSessionFactory();
NHibernate.ISession session = sFactory.OpenSession();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
示例3: init
public void init()
{
cfg = new Configuration();
cfg.Configure();
/* Add xml mappings created manually
* - Because Web Site projects are only compiled during runtime, the hibernate mapping files will need to
* be discovered and added to the assembly at runtime.
*/
cfg.AddDirectory(new DirectoryInfo(HttpContext.Current.Server.MapPath("~/Mapping")));
//Add your custom configurations here to override the Hibernate.xml configuration.
}
示例4: InitHibernate
public static void InitHibernate()
{
Debug.WriteLine("Configuring Hibernate...");
Log.Info("hello");
var cfg = new Configuration();
HbmSerializer.Default.Validate = true;
HbmSerializer.Default.Serialize(Environment.CurrentDirectory, Assembly.GetExecutingAssembly());
cfg.AddDirectory(new DirectoryInfo(Environment.CurrentDirectory));
var sessionFactory = cfg.Configure().BuildSessionFactory();
SessionFactory = sessionFactory;
Debug.WriteLine("Created SessionFactory!");
}
示例5: OpenSession
/// <summary>
/// Method to create session and manage entities
/// </summary>
/// <returns></returns>
ISession OpenSession()
{
if (sessionFactory == null)
{
var cgf = new Configuration();
var data = cgf.Configure("c:\\users\\matute\\documents\\visual studio 2015\\Projects\\NHibernate_Expo\\NHibernate_Expo\\Models\\NHibernate\\Configuration\\hibernate.cfg.xml");
cgf.AddDirectory(new System.IO.DirectoryInfo("c:\\users\\matute\\documents\\visual studio 2015\\Projects\\NHibernate_Expo\\NHibernate_Expo\\Models\\NHibernate\\Mappings"));
//var data = cgf.Configure(HttpContext.Current.Server.MapPath(@"Models\NHibernate\Configuration\hibernate.cfg.xml"));
//cgf.AddDirectory(new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"Models\NHibernate\Mappings")));
sessionFactory = data.BuildSessionFactory();
}
return sessionFactory.OpenSession();
}
示例6: CreateProvider
public override DomainServiceDescriptionProvider CreateProvider(Type domainServiceType, DomainServiceDescriptionProvider parent)
{
string currentDir = AppDomain.CurrentDomain.BaseDirectory;
Configuration cfg = null;
try
{
cfg = new Configuration();
cfg.Configure(_nHibernateConfigurationPath);
cfg.AddDirectory(new DirectoryInfo(currentDir));
}
catch
{
throw;
}
return new NHibernateTypeDescriptionProvider(domainServiceType, parent, cfg);
}
示例7: Build
public Configuration Build()
{
Configuration cfg = LoadConfigurationFromFile();
if (cfg == null)
{
foreach (TelChina.AF.Sys.Configuration.AddElement item in AFConfigurationManager.PLGroup.Storages)
{
var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, item.FileName);
cfg = new NHibernate.Cfg.Configuration();
cfg.Configure(fileName);
//设置实体映射文件关联
var mappingFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CONFIGPATH);
cfg.AddDirectory(new System.IO.DirectoryInfo(mappingFileName));
}
SaveConfigurationToFile(cfg);
}
return cfg;
}
示例8: OpenSession
/// <summary>
/// Method to create session and manage entities
/// </summary>
/// <returns></returns>
ISession OpenSession()
{
if (sessionFactory == null)
{
var cgf = new Configuration();
var data = cgf.Configure(HttpContext.Current.Server.MapPath(@"Models\NHibernate\Configuration\hibernate.cfg.xml"));
cgf.AddDirectory(new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"Models\NHibernate\Mappings")));
sessionFactory = data.BuildSessionFactory();
}
return sessionFactory.OpenSession();
}