Пример #1
0
        static async Task Main(String[] args)
        {
            //PerformanceCacheTest.RunTest(100);
            new PLNull(new PLNull_DbFixtureInitDb()).ApplyFilterGroupBy(0).GetAwaiter().GetResult();
            //new ProcedureTest().ScalarFunction_get().GetAwaiter().GetResult();
            //new PLNull_ManyColumns(new PLNull_ManyColumnsFixtureInitDb()).Filter(1).GetAwaiter().GetResult();

            InformationSchemaMapping informationSchemaMapping = GetMappings();
            ProviderSpecificSchema   providerSchema           = CreateSchemaSqlServer(true);

            EdmModel dynamicEdmModel;

            using (var metadataProvider = providerSchema.CreateMetadataProvider(informationSchemaMapping))
            {
                DynamicTypeDefinitionManager typeDefinitionManager = DynamicTypeDefinitionManager.Create(metadataProvider);
                var dataAdapter = new DynamicDataAdapter(typeDefinitionManager);
                dynamicEdmModel = dataAdapter.BuildEdmModel(metadataProvider);
            }
            String csdlSchema = TestHelper.GetCsdlSchema(dynamicEdmModel);

            var parser = new OeParser(new Uri("http://dummy"), dynamicEdmModel);
            var stream = new MemoryStream();
            await parser.ExecuteGetAsync(new Uri("http://dummy/Orders?$expand=Customer,Items&$orderby=Id"), OeRequestHeaders.JsonDefault, stream, CancellationToken.None);

            stream.Position = 0;
            String result = new StreamReader(stream).ReadToEnd();
        }
Пример #2
0
        public DynamicModelBuilder(DynamicMetadataProvider metadataProvider, DynamicTypeDefinitionManager typeDefinitionManager)
        {
            MetadataProvider      = metadataProvider;
            TypeDefinitionManager = typeDefinitionManager;

            _entityTypes = new Dictionary <String, EntityType>();
        }
Пример #3
0
        private static DynamicTypeDefinitionManager CreateTypeDefinitionManager(bool useRelationalNulls)
        {
            IEdmModel edmModel         = new OeEdmModelBuilder(new OrderDataAdapter(), new OeEdmModelMetadataProvider()).BuildEdmModel();
            var       metadataProvider = new EdmDynamicMetadataProvider(edmModel);

            return(DynamicTypeDefinitionManager.Create(DynamicDbContext.CreateOptions(useRelationalNulls), metadataProvider));
        }
Пример #4
0
        static async Task Main()
        {
            //PerformanceCacheTest.RunTest(100);
            await new PLNull(new PLNull_DbFixtureInitDb()).OrderByColumnsMissingInSelect(0);
            //new PLNull_ManyColumns(new PLNull_ManyColumnsFixtureInitDb()).Filter(1).GetAwaiter().GetResult();

            IEdmModel edmModel         = new OeEdmModelBuilder(new OrderDataAdapter(), new OeEdmModelMetadataProvider()).BuildEdmModel();
            var       metadataProvider = new EdmDynamicMetadataProvider(edmModel);

            DbContextOptions options  = DynamicDbContext.CreateOptions(true);
            var typeDefinitionManager = DynamicTypeDefinitionManager.Create(options, metadataProvider);

            ////var dbContext = typeDefinitionManager.CreateDynamicDbContext();
            ////var orders = typeDefinitionManager.GetQueryable(dbContext, "Orders");
            ////var zzz = orders.Include("Items").Include("AltCustomer").Include("Customer").Include("ShippingAddresses").ToList();

            ////var orderItems = typeDefinitionManager.GetQueryable(dbContext, "OrderItems");
            ////var zzz2 = orderItems.Include("Order").ToList();

            ////dbContext = new DynamicDbContext(options, typeDefinitionManager);
            ////var zzz3 = new InternalDbSet<DynamicType01>(dbContext).ToList();

            var dataAdapter     = new DynamicDataAdapter(typeDefinitionManager);
            var dynamicEdmModel = dataAdapter.BuildEdmModel();

            String schema = TestHelper.GetCsdlSchema(dynamicEdmModel);

            var parser = new OeParser(new Uri("http://dummy"), dynamicEdmModel);
            var stream = new MemoryStream();
            //await parser.ExecuteGetAsync(new Uri("http://dummy/Orders?$expand=Customer,Items&$orderby=Id"), OeRequestHeaders.JsonDefault, stream, CancellationToken.None);
            await parser.ExecuteGetAsync(new Uri("http://dummy/Orders"), OeRequestHeaders.JsonDefault, stream, CancellationToken.None);

            stream.Position = 0;
            String result = new StreamReader(stream).ReadToEnd();
        }
Пример #5
0
        private static EdmModel CreateDynamicEdmModel(bool useRelationalNulls)
        {
            ProviderSpecificSchema providerSchema = DynamicDataContext.Program.CreateSchemaSqlServer(useRelationalNulls);
            //ProviderSpecificSchema providerSchema = DynamicDataContext.Program.CreateSchemaPostgreSql(useRelationalNulls);
            //ProviderSpecificSchema providerSchema = DynamicDataContext.Program.CreateSchemaMySql(useRelationalNulls);

            InformationSchemaSettings informationSchemaSettings = DynamicDataContext.Program.GetSettings();

            using (var metadataProvider = providerSchema.CreateMetadataProvider(informationSchemaSettings))
            {
                var typeDefinitionManager = DynamicTypeDefinitionManager.Create(metadataProvider);
                var dataAdapter           = new DynamicDataAdapter(typeDefinitionManager);
                return(dataAdapter.BuildEdmModel(metadataProvider));
            }
        }
Пример #6
0
        private static EdmModel CreateDynamicEdmModel(bool useRelationalNulls)
        {
            //DbContextOptions<DynamicDbContext> options = OrderContextOptions.Create<DynamicDbContext>(useRelationalNulls);
            //var informationSchema = new SqlServerSchema(options);
            DbContextOptions <DynamicDbContext> options = DynamicDataContext.Program.CreateOptionsPostgreSql(useRelationalNulls);
            var informationSchema = new PostgreSqlSchema(options);

            InformationSchemaMapping informationSchemaMapping = DynamicDataContext.Program.GetMappings();

            using (var metadataProvider = new DynamicMetadataProvider(informationSchema, informationSchemaMapping))
            {
                var typeDefinitionManager = DynamicTypeDefinitionManager.Create(metadataProvider);
                var dataAdapter           = new DynamicDataAdapter(typeDefinitionManager);
                return(dataAdapter.BuildEdmModel(metadataProvider));
            }
        }
Пример #7
0
        static async Task Main()
        {
            //PerformanceCacheTest.RunTest(100);
            await new PLNull(new PLNull_DbFixtureInitDb()).ExpandExpandMany(0, false);
            //new ProcedureTest().TableFunction_get().GetAwaiter().GetResult();
            //new PLNull_ManyColumns(new PLNull_ManyColumnsFixtureInitDb()).Filter(1).GetAwaiter().GetResult();

            //IEdmModel edmModel = new OeEdmModelBuilder(new OrderDataAdapter(), new OeEdmModelMetadataProvider()).BuildEdmModel();
            //var metadataProvider = new EdmDynamicMetadataProvider(edmModel);
            InformationSchemaMapping informationSchemaMapping = GetMappings();
            //var informationSchema = new SqlServerSchema(CreateOptionsSqlServer(true));
            var informationSchema = new PostgreSqlSchema(CreateOptionsPostgreSql(true));

            EdmModel dynamicEdmModel;

            using (var metadataProvider = new DynamicMetadataProvider(informationSchema, informationSchemaMapping))
            {
                DynamicTypeDefinitionManager typeDefinitionManager = DynamicTypeDefinitionManager.Create(metadataProvider);
                var dataAdapter = new DynamicDataAdapter(typeDefinitionManager);
                dynamicEdmModel = dataAdapter.BuildEdmModel(metadataProvider);
            }
            String csdlSchema = TestHelper.GetCsdlSchema(dynamicEdmModel);

            //var dbContext = typeDefinitionManager.CreateDynamicDbContext();
            //var orders = typeDefinitionManager.GetQueryable(dbContext, "Orders");
            //var zzz = orders.Include("Items").Include("AltCustomer").Include("Customer").Include("ShippingAddresses").ToList();

            //var orderItems = typeDefinitionManager.GetQueryable(dbContext, "OrderItems");
            //var zzz2 = orderItems.Include("Order").ToList();

            //dbContext = new DynamicDbContext(options, typeDefinitionManager);
            //var zzz3 = new InternalDbSet<DynamicType01>(dbContext).ToList();

            var parser = new OeParser(new Uri("http://dummy"), dynamicEdmModel);
            var stream = new MemoryStream();
            //await parser.ExecuteGetAsync(new Uri("http://dummy/Orders?$expand=Customer,Items&$orderby=Id"), OeRequestHeaders.JsonDefault, stream, CancellationToken.None);
            await parser.ExecuteGetAsync(new Uri("http://dummy/Orders"), OeRequestHeaders.JsonDefault, stream, CancellationToken.None);

            stream.Position = 0;
            String result = new StreamReader(stream).ReadToEnd();
        }
Пример #8
0
 public DynamicEdmModelMetadataProvider(IModel model, DynamicMetadataProvider dynamicMetadataProvider, DynamicTypeDefinitionManager typeDefinitionManager) : base(model)
 {
     _dynamicMetadataProvider = dynamicMetadataProvider;
     _typeDefinitionManager   = typeDefinitionManager;
 }
Пример #9
0
 public DynamicDbContext02(DbContextOptions options, DynamicTypeDefinitionManager typeDefinitionManager)
     : base(options, typeDefinitionManager)
 {
 }
Пример #10
0
 protected DynamicDbContext(DbContextOptions options, DynamicTypeDefinitionManager typeDefinitionManager) : base(options)
 {
     TypeDefinitionManager = typeDefinitionManager;
 }