MCa*_*ale 5 c# asp.net nhibernate fluent-nhibernate
我正在使用Fluent NHibernate,需要从hibernate.cfg.xml文件的connection.connection_string属性获取我的Connection String 来创建Session Factory:
private static ISessionFactory SessionFactory {
get {
return = Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(c => c.FromConnectionStringWithKey("MyConnStr")))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<FooMap>())
.ExposeConfiguration(c => c.Properties.Add("hbm2ddl.keywords", "none"))
.BuildSessionFactory();
}
}
Run Code Online (Sandbox Code Playgroud)
我想替换来自hibernate.cfg.xml文件的连接字符串的MyConnStr(在我的web.config文件中)" c => c.FromConnectionStringWithKey("MyConnStr") " .
我尝试过使用NHibernate.Cfg.Environment.ConnectionString,但它没有用.
我怎么能得到这个?
谢谢.
Jag*_*uar 11
试试这个
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration().Configure();
string conString = cfg.Configuration.GetProperty(NHibernate.Cfg.Environment.ConnectionString);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7199 次 |
| 最近记录: |