Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Fluente NHibernate 3 e Oracle.DataAccess


Aqui está um trecho de código de trabalho:
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");
        });
}

Sem especificar um provedor, ele seleciona automaticamente o Oracle DataAccess.

Editar: Ele não buscá-lo automaticamente, eu apenas o tenho na minha string de conexão:
<add name="development" connectionString="Data Source=XXX;User ID=yyy;Password=zzz;" providerName="Oracle.DataAccess.Client"/>