Fluent NHibernate 3 and Oracle.DataAccess

丶灬走出姿态 提交于 2019-12-06 06:58:43

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