Example #1
0
        private static void PerformanceCacheOeTest(SelectTestDefinition[] testDefinitions, int testCount, bool cache)
        {
            var dataAdapter = new OeEfCoreDataAdapter <OrderContext>(new Db.OeQueryCache()
            {
                AllowCache = cache
            });
            IEdmModel edmModel = OeEdmModelBuilder.BuildEdmModel(dataAdapter);
            var       parser   = new OeParser(new Uri("http://dummy"), dataAdapter, edmModel);

            GC.Collect();
            GC.WaitForPendingFinalizers();

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            for (int i = 0; i < testCount; i++)
            {
                foreach (SelectTestDefinition testDefinition in testDefinitions)
                {
                    var uri = new Uri("http://dummy/" + testDefinition.Request);
                    using (var response = new MemoryStream())
                        parser.ExecuteQueryAsync(uri, OeRequestHeaders.Default, response, CancellationToken.None).GetAwaiter().GetResult();
                }
            }
            stopWatch.Stop();
            Console.WriteLine("OdataToEntity cache = " + cache + " " + stopWatch.Elapsed);
        }
        public static EdmModel BuildEdmModel(this OeDataAdapter dataAdapter)
        {
            var modelBuilder = new OeEdmModelBuilder(dataAdapter.EntitySetMetaAdapters.EdmModelMetadataProvider, dataAdapter.EntitySetMetaAdapters.ToDictionary());

            BuildOperations(dataAdapter, modelBuilder);
            return(modelBuilder.BuildEdmModel());
        }
 public EdmModel BuildEdmModel()
 {
     using (DynamicDbContext context = _typeDefinitionManager.CreateDynamicDbContext())
     {
         var modelBuilder = new OeEdmModelBuilder(this, new DynamicEdmModelMetadataProvider(context.Model, _typeDefinitionManager));
         return(modelBuilder.BuildEdmModel());
     }
 }
Example #4
0
 public static EdmModel BuildEdmModelFromEf6Model(this Db.OeDataAdapter dataAdapter)
 {
     using (var context = (DbContext)dataAdapter.CreateDataContext())
     {
         var modelBuilder = new OeEdmModelBuilder(dataAdapter, new OeEf6EdmModelMetadataProvider(context));
         return(modelBuilder.BuildEdmModel());
     }
 }
        public static EdmModel BuildEdmModel(this Db.OeDataAdapter dataAdapter)
        {
            var modelBuilder = new OeEdmModelBuilder(dataAdapter.EntitySetMetaAdapters.EdmModelMetadataProvider);

            modelBuilder.AddEntitySetRange(dataAdapter.EntitySetMetaAdapters.GetEntitySetNamesEntityTypes());
            BuildOperations(dataAdapter, modelBuilder);
            return(modelBuilder.BuildEdmModel());
        }
Example #6
0
 private static EdmModel BuildEdmModelFromEf6Model(OeDataAdapter dataAdapter)
 {
     using (var context = (DbContext)dataAdapter.CreateDataContext())
     {
         var metadataProvider = new OeEf6EdmModelMetadataProvider(context);
         var modelBuilder     = new OeEdmModelBuilder(metadataProvider);
         modelBuilder.AddEntitySetRange(dataAdapter.EntitySetAdapters.GetEntitySetNamesEntityTypes());
         FixOperations(dataAdapter, modelBuilder);
         return(modelBuilder.BuildEdmModel());
     }
 }
Example #7
0
        public static EdmModel BuildEdmModelFromEfCoreModel(this Db.OeDataAdapter dataAdapter, Type[] excludeTypes, params IEdmModel[] refModels)
        {
            var context = (DbContext)dataAdapter.CreateDataContext();

            try
            {
                var modelBuilder = new OeEdmModelBuilder(dataAdapter, new OeEfCoreEdmModelMetadataProvider(context.Model));
                return(modelBuilder.BuildEdmModel(excludeTypes, refModels));
            }
            finally
            {
                dataAdapter.CloseDataContext(context);
            }
        }
        public EdmModel BuildEdmModel(ModelBuilder.DynamicMetadataProvider metadataProvider)
        {
            using (Types.DynamicDbContext context = TypeDefinitionManager.CreateDynamicDbContext())
            {
                var edmModelMetadataProvider = new ModelBuilder.DynamicEdmModelMetadataProvider(context.Model, metadataProvider, TypeDefinitionManager);
                var modelBuilder             = new OeEdmModelBuilder(this, edmModelMetadataProvider);

                foreach (OeOperationConfiguration operationConfiguration in metadataProvider.GetRoutines(TypeDefinitionManager))
                {
                    modelBuilder.AddOperation(operationConfiguration);
                }

                return(modelBuilder.BuildEdmModel());
            }
        }
Example #9
0
        public static EdmModel BuildEdmModelFromEfCorePgSqlModel(this Db.OeDataAdapter dataAdapter, String schema, params IEdmModel[] refModels)
        {
            var context = (DbContext)dataAdapter.CreateDataContext();

            try
            {
                var model = (Model)context.Model;
                model.Relational().DefaultSchema = schema;
                var modelBuilder = new OeEdmModelBuilder(dataAdapter, new OeEfCoreEdmModelMetadataProvider(model));
                return(modelBuilder.BuildEdmModel(refModels));
            }
            finally
            {
                dataAdapter.CloseDataContext(context);
            }
        }
        public static EdmModel BuildEdmModelFromEfCoreModel(this Db.OeDataAdapter dataAdapter)
        {
            var context = (DbContext)dataAdapter.CreateDataContext();

            try
            {
                var metadataProvider = new OeEfCoreEdmModelMetadataProvider(context.Model);
                var modelBuilder     = new OeEdmModelBuilder(metadataProvider);
                modelBuilder.AddEntitySetRange(dataAdapter.EntitySetMetaAdapters.GetEntitySetNamesEntityTypes());
                OeDataAdapterExtension.BuildOperations(dataAdapter, modelBuilder);
                return(modelBuilder.BuildEdmModel());
            }
            finally
            {
                dataAdapter.CloseDataContext(context);
            }
        }
        public static EdmModel BuildEdmModelFromLinq2DbModel(this Db.OeDataAdapter dataAdapter, params IEdmModel[] refModels)
        {
            var modelBuilder = new OeEdmModelBuilder(dataAdapter, new OeLinq2DbEdmModelMetadataProvider());

            return(modelBuilder.BuildEdmModel(refModels));
        }
Example #12
0
        public static EdmModel BuildEdmModel(this Db.OeDataAdapter dataAdapter, Type[] excludedTypes, params IEdmModel[] refModels)
        {
            var modelBuilder = new OeEdmModelBuilder(dataAdapter, new OeEdmModelMetadataProvider());

            return(modelBuilder.BuildEdmModel(excludedTypes, refModels));
        }