private static void DoAdd(IServiceCollection services, IConfiguration config, OracleServiceInfo info, Type dbContextType, ServiceLifetime contextLifetime)
        {
            var oracleConfig = new OracleProviderConnectorOptions(config);

            var factory = new OracleDbContextConnectorFactory(info, oracleConfig, dbContextType);

            services.Add(new ServiceDescriptor(dbContextType, factory.Create, contextLifetime));
        }
Exemple #2
0
        private static void DoAdd(IServiceCollection services, IConfiguration config, OracleServiceInfo info, Type dbContextType, ServiceLifetime contextLifetime, ILogger logger = null)
        {
            var oracleConfig = new OracleProviderConnectorOptions(config);

            var factory = new OracleDbContextConnectorFactory(info, oracleConfig, dbContextType);

            services.Add(new ServiceDescriptor(dbContextType, factory.Create, contextLifetime));
            try
            {
                var healthFactory = new OracleProviderConnectorFactory(info, oracleConfig, OracleTypeLocator.OracleConnection);
                services.Add(new ServiceDescriptor(typeof(IHealthContributor), ctx => new RelationalDbHealthContributor((IDbConnection)healthFactory.Create(ctx), ctx.GetService <ILogger <RelationalDbHealthContributor> >()), contextLifetime));
            }
            catch (TypeLoadException)
            {
                logger?.LogWarning("Failed to add a HealthContributor for the Oracle DbContext");
            }
        }
Exemple #3
0
        public void Create_ReturnsDbContext()
        {
            OracleProviderConnectorOptions config = new OracleProviderConnectorOptions()
            {
                Server      = "localhost",
                Port        = 1521,
                Password    = "******",
                Username    = "******",
                ServiceName = "ORCLCDB"
            };
            OracleServiceInfo si = new OracleServiceInfo("MyId", "Oracle://*****:*****@192.168.0.90:3306/cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355");
            var factory          = new OracleDbContextConnectorFactory(si, config, typeof(GoodOracleDbContext));
            var context          = factory.Create(null);

            Assert.NotNull(context);
            GoodOracleDbContext gcontext = context as GoodOracleDbContext;

            Assert.NotNull(gcontext);
        }