我使用流利NHibernate,我喜歡它! 我有一個小問題:啓動時間大約是10秒,我不知道如何優化Fluent nHibernate 爲了使啓動時間更少問題,我把它放在一個線程上。流利的nHibernate慢啓動時間
有人可以告訴解決這個問題嗎?並修改下面的代碼以改善性能以改善性能?
我看到這樣的: http://nhforge.org/blogs/nhibernate/archive/2009/03/13/an-improvement-on-sessionfactory-initialization.aspx 但我不知道如何使這與Fluent nHibernate一起工作。
我的代碼是這樣的:
public static ISession ObterSessao()
{
System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest;
string ConnectionString = ConfigurationHelper.LeConfiguracaoWeb("EstoqueDBNet"); // My Connection string goes here
var config = Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MySQLConfiguration.Standard.ConnectionString(ConnectionString));
config.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()));
var session = config
.BuildSessionFactory()
.OpenSession();
System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal;
return session;
}
嗨,我怎麼能將配置對象存儲在一個文件,所以當我再次運行我的程序時,我可以讀取它(反序列化)並快速啓動程序?我嘗試在上面的代碼中序列化配置對象,但它只返回了這個:<?xml version =「1.0」?> –
Tony
2010-12-08 00:12:22
您可以將代碼放入靜態構造函數中,並將SessionFactory分配給返回ISessionFactory的靜態屬性。然後調用obtersesao.OpenSession() – Phill 2010-12-08 00:20:59
有沒有辦法將工廠存儲(序列化)在一個文件中,並在稍後恢復?由於我的應用程序是一個可執行文件,每次用戶運行它時,都會有10秒的延遲。 – Tony 2010-12-08 01:15:19