Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            String basePath           = Configuration.GetValue <String>("OdataToEntity:BasePath");
            String provider           = Configuration.GetValue <String>("OdataToEntity:Provider");
            String connectionString   = Configuration.GetValue <String>("OdataToEntity:ConnectionString");
            bool   useRelationalNulls = Configuration.GetValue <bool>("OdataToEntity:UseRelationalNulls");
            String informationSchemaMappingFileName = Configuration.GetValue <String>("OdataToEntity:InformationSchemaMappingFileName");

            if (!String.IsNullOrEmpty(basePath) && basePath[0] != '/')
            {
                basePath = "/" + basePath;
            }

            InformationSchemaMapping?informationSchemaMapping = null;

            if (informationSchemaMappingFileName != null)
            {
                String json = File.ReadAllText(informationSchemaMappingFileName);
                informationSchemaMapping = Newtonsoft.Json.JsonConvert.DeserializeObject <InformationSchemaMapping>(json);
            }

            var schemaFactory = new DynamicSchemaFactory(provider, connectionString);

            using (ProviderSpecificSchema providerSchema = schemaFactory.CreateSchema(useRelationalNulls))
            {
                IEdmModel edmModel = DynamicMiddlewareHelper.CreateEdmModel(providerSchema, informationSchemaMapping);
                app.UseOdataToEntityMiddleware <OePageMiddleware>(basePath, edmModel);
            }
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            String basePath           = Configuration.GetValue <String>("OdataToEntity:BasePath");
            String provider           = Configuration.GetValue <String>("OdataToEntity:Provider");
            String connectionString   = Configuration.GetValue <String>("OdataToEntity:ConnectionString");
            bool   useRelationalNulls = Configuration.GetValue <bool>("OdataToEntity:UseRelationalNulls");
            String?informationSchemaMappingFileName = Configuration.GetValue <String>("OdataToEntity:InformationSchemaMappingFileName");
            String?filter        = Configuration.GetValue <String>("OdataToEntity:Filter");
            String?defaultSchema = Configuration.GetSection("OdataToEntity:DefaultSchema").Get <String>();

            String[]? includedSchemas = Configuration.GetSection("OdataToEntity:IncludedSchemas").Get <String[]>();
            String[]? excludedSchemas = Configuration.GetSection("OdataToEntity:ExcludedSchemas").Get <String[]>();

            if (!String.IsNullOrEmpty(basePath) && basePath[0] != '/')
            {
                basePath = "/" + basePath;
            }

            var informationSchemaSettings = new InformationSchemaSettings();

            if (!String.IsNullOrEmpty(defaultSchema))
            {
                informationSchemaSettings.DefaultSchema = defaultSchema;
            }
            if (includedSchemas != null)
            {
                informationSchemaSettings.IncludedSchemas = new HashSet <String>(includedSchemas);
            }
            if (excludedSchemas != null)
            {
                informationSchemaSettings.ExcludedSchemas = new HashSet <String>(excludedSchemas);
            }
            if (filter != null)
            {
                informationSchemaSettings.ObjectFilter = Enum.Parse <DbObjectFilter>(filter, true);
            }
            if (informationSchemaMappingFileName != null)
            {
                String json = File.ReadAllText(informationSchemaMappingFileName);
                var    informationSchemaMapping = System.Text.Json.JsonSerializer.Deserialize <InformationSchemaMapping>(json) !;
                informationSchemaSettings.Operations = informationSchemaMapping.Operations;
                informationSchemaSettings.Tables     = informationSchemaMapping.Tables;
            }

            var schemaFactory = new DynamicSchemaFactory(provider, connectionString);

            using (ProviderSpecificSchema providerSchema = schemaFactory.CreateSchema(useRelationalNulls))
            {
                IEdmModel edmModel = DynamicMiddlewareHelper.CreateEdmModel(providerSchema, informationSchemaSettings);
                app.UseOdataToEntityMiddleware <OePageMiddleware>(basePath, edmModel);
            }
        }
Beispiel #3
0
        public static ProviderSpecificSchema CreateSchemaMySql(bool useRelationalNulls)
        {
            var optionsFactory = new DynamicSchemaFactory("mysql", "server=localhost;database=dbo;user=root;password=123456");

            return(optionsFactory.CreateSchema(useRelationalNulls));
        }
Beispiel #4
0
        public static ProviderSpecificSchema CreateSchemaPostgreSql(bool useRelationalNulls)
        {
            var optionsFactory = new DynamicSchemaFactory("postgresql", "Host=localhost;Port=5432;Database=OdataToEntity;Pooling=true");

            return(optionsFactory.CreateSchema(useRelationalNulls));
        }
Beispiel #5
0
        public static ProviderSpecificSchema CreateSchemaSqlServer(bool useRelationalNulls)
        {
            var optionsFactory = new DynamicSchemaFactory("sqlserver", @"Server=.\sqlexpress;Initial Catalog=OdataToEntity;Trusted_Connection=Yes;");

            return(optionsFactory.CreateSchema(useRelationalNulls));
        }