标签:blog http io ar for strong sp 文件 数据
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NJ12369.SendInfo">
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">server=192.168.10.127;uid=;pwd=sa;database=b</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="use_outer_join">true</property>
<property name="query.substitutions">true 1, false 0, yes ‘Y‘, no ‘N‘</property>
<!-- mapping files -->
<mapping assembly="*****" />
</session-factory>
</hibernate-configuration>
HttpContext.Current.Server.MapPath("~/fileName.config");
3.
读取文件信息
Configuration cfg = new Configuration().Configure(fileName);
pulic static class ConfigurationFactory
{
private static Hashtable cfgs = new Hashtable();
static ConfigurationFactory(){
foreach( string path in GetPaths() )
{
Configuration cfg = new Configuration();
cfg.Configure(new XmlTextReader(new StreamReader( path ));
cfgs.Add( GetName(path), cfg );
}
}
public static Configuration GetCfg( string cfgName ){
return cfgs[ cfgName ] as Configuration;
}
public static string[] GetPaths(){
/*这个按你的实际情况来写*/
}
public static string GetName(string path ){
/*这个按你的实际情况来写*/
}
}
注意:
在增加的hiberante.cfg.xml文件里去掉<mapping assembly="*****" />
数据库参数配置请参照:
网址:http://blog.csdn.net/hsg77/article/details/23463733
标签:blog http io ar for strong sp 文件 数据
原文地址:http://www.cnblogs.com/ManBlog/p/4041731.html