1
我試圖配置會話,但視覺工作室告訴我無法在dbConfigObject中指定時創建驅動程序。如何在使用流暢的Nhibernate時配置驅動程序?
我在App.config中有Oracle.DataAccess庫和我的連接字符串。 我在FluentNhibernateHelper代碼是這樣的:
public static class FluentNHibernateHelper
{
private static ISessionFactory _sessionFactory;
public static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
var dbConfig = OracleDataClientConfiguration.Oracle10
.ConnectionString(c => c.FromConnectionStringWithKey("Oracle"))
.Driver<OracleDataClientDriver>()
.ShowSql();
_sessionFactory = Fluently.Configure()
.Database(dbConfig)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Empleado>())
.BuildSessionFactory();
}
return _sessionFactory;
}
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}
}