Fluent NHibernate 3 and Oracle.DataAccess

给你一囗甜甜゛ 提交于 2019-12-08 01:31:46

问题


my question:

I am trying to use Oracle.DataAccess.Client Provider with NHibernate (Fluent), and I configured it as follows:

Fluently.Configure().Database(OracleClientConfiguration.Oracle10.Provider("Oracle.DataAccess.Client").ConnectionString(c => c.FromConnectionStringWithKey("ORACLE1"))).

and I have this error:

"Could not load type Oracle.DataAccess.Client. Possible cause: no assembly name specified.":"

I already add Reference to Oracle.Dataaccess dll (ODAC) with copy local = true, but error persist...

Any suggestions?


回答1:


Here's a working code snippet:

public static void InitializeNHibernate()
{
    var configurer = (OracleClientConfiguration.Oracle10.ShowSql().ConnectionString(c =>
                 c.FromConnectionStringWithKey("development"))
                 .DefaultSchema("myschema")
                 .UseReflectionOptimizer()
                 .Cache(c =>
                         c.ProviderClass<SysCacheProvider>()
                         .UseQueryCache()));

    var cfg = Fluently.Configure()
        .Database(configurer)
        .Mappings(m =>
                      {
                          m.FluentMappings
                              .AddFromAssemblyOf<Employee>()
                              .Conventions.Add<OracleDateTimeTypeConvention>();

                          m.HbmMappings
                              .AddFromAssemblyOf<Employee>();
                      })
        .ExposeConfiguration(configuration =>
        {
            configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
            configuration.SetProperty(Environment.GenerateStatistics, "true");
            configuration.SetProperty(Environment.CurrentSessionContextClass, "web");
            configuration.SetProperty(Environment.CommandTimeout, "60");
        });
}

Without specifying a provider, it automatically picks Oracle DataAccess up.

Edit: It does not pick it up automatically, I just have it on my connection string:

<add name="development" connectionString="Data Source=XXX;User ID=yyy;Password=zzz;" providerName="Oracle.DataAccess.Client"/>


来源:https://stackoverflow.com/questions/6095496/fluent-nhibernate-3-and-oracle-dataaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!