Exemplo n.º 1
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapODataRoute(
                routeName: "odata",
                routePrefix: "odata",
                model: EdmBuilder.GetEdm <TodoListContext>(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );


            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            // Only used by TestController
            config.Routes.MapHttpRoute(
                name: "BreezeApi",
                routeTemplate: "breeze/{controller}/{action}"
                );
        }
Exemplo n.º 2
0
        public NavigationTest(ODatalizerWebApplicationFactory <Startup> factory)
        {
            _client = factory.CreateClient();

            using var scope = factory.Server.Services.CreateScope();
            _edm            = EdmBuilder.Build(scope.ServiceProvider.GetRequiredService <SampleDbContext>());
        }
Exemplo n.º 3
0
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapODataRoute(
                routeName: "odata",
                routePrefix: "odata",
                model: EdmBuilder.GetEdm <NorthwindIBContext_CF>(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            //ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            //builder.EntitySet<Product>("Products");
            //builder.EntitySet<Customer>("Customers");
            //builder.EntitySet<Order>("Order");
            //builder.EntitySet<Category>("Categories");
            //builder.EntitySet<Supplier>("Suppliers");
            //config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel());

            //// Web API configuration and services

            //// Web API routes
            //config.MapHttpAttributeRoutes();

            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);
        }
Exemplo n.º 4
0
        public static void Register(HttpConfiguration config)
        {
            // standard Web API routes
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            // OData
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <Customer>("Customers");
            builder.EntitySet <Invoice>("Invoices");

            // OData Action
            ActionConfiguration purchase = builder.Entity <Customer>().Action("Purchase");

            purchase.Parameter <int>("AmountOfShoes");
            purchase.ReturnsFromEntitySet <Invoice>("Invoices");

            config.Routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());

            // OData with fixed metadata
            // see: http://www.getbreezenow.com/documentation/odata-server
            config.Routes.MapODataServiceRoute("odataFixed", "odataFixed", EdmBuilder.GetEdm <DataContext>(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
        }
Exemplo n.º 5
0
 public ODatalizerEndpoint(DbContext db, string routeName = null, string routePrefix = null, string controller = null, string @namespace = null, bool authorize = false)
 {
     DbContext            = db;
     Namespace            = @namespace;
     ODatalizerController = controller;
     RouteName            = routeName;
     RoutePrefix          = routePrefix;
     Authorize            = authorize;
     EdmModel             = EdmBuilder.Build(db);
 }
Exemplo n.º 6
0
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapODataRoute(
                routeName: "NorthwindIB_ODATA",
                routePrefix: "NorthwindIB_odata",
                model: EdmBuilder.GetEdm <NorthwindIBContext_Aliased>(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );



            var billingModel = EdmBuilder.GetEdm <InheritanceContext>();

            config.Routes.MapODataRoute(
                routeName: "BillingInheritance_ODATA",
                routePrefix: "BillingInheritance_odata",
                model: billingModel,
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            var produceModel = EdmBuilder.GetEdm <ProduceTPHContext>();

            config.Routes.MapODataRoute(
                routeName: "ProduceInheritance_ODATA",
                routePrefix: "ProduceInheritance_odata",
                model: produceModel,
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            // If using ODataConventionModelBuilder
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <Product>("Products");
            builder.EntitySet <Customer>("Customers");
            builder.EntitySet <Order>("Order");
            builder.EntitySet <Category>("Categories");
            builder.EntitySet <Supplier>("Suppliers");

            config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel());


            // From Original template

            //// Web API configuration and services

            //// Web API routes
            //config.MapHttpAttributeRoutes();

            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);
        }
Exemplo n.º 7
0
        public static void RegistePreStart()
        {
            // New code:

            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <Categories>("Categories");
            builder.EntitySet <CustomerDemographics>("CustomerDemographics");
            builder.EntitySet <Customers>("Customers");
            builder.EntitySet <Employees>("Employees");
            builder.EntitySet <Order_Details>("Order_Details");
            builder.EntitySet <Orders>("Orders");
            builder.EntitySet <Products>("Products");
            builder.EntitySet <Region>("Region");
            builder.EntitySet <Shippers>("Shippers");
            builder.EntitySet <Suppliers>("Suppliers");
            builder.EntitySet <Territories>("Territories");
            builder.EntitySet <Alphabetical_list_of_products>("Alphabetical_list_of_products");
            builder.EntitySet <Category_Sales_for_1997>("Category_Sales_for_1997");
            builder.EntitySet <Current_Product_List>("Current_Product_List");
            builder.EntitySet <Customer_and_Suppliers_by_City>("Customer_and_Suppliers_by_City");
            builder.EntitySet <Invoices>("Invoices");
            builder.EntitySet <Order_Details_Extended>("Order_Details_Extended");
            builder.EntitySet <Order_Subtotals>("Order_Subtotals");
            builder.EntitySet <Orders_Qry>("Orders_Qry");
            builder.EntitySet <Product_Sales_for_1997>("Product_Sales_for_1997");
            builder.EntitySet <Products_Above_Average_Price>("Products_Above_Average_Price");
            builder.EntitySet <Products_by_Category>("Products_by_Category");
            builder.EntitySet <Sales_Totals_by_Amount>("Sales_Totals_by_Amount");
            builder.EntitySet <Summary_of_Sales_by_Quarter>("Summary_of_Sales_by_Quarter");
            builder.EntitySet <Summary_of_Sales_by_Year>("Summary_of_Sales_by_Year");


            //builder.GetEdmModel());
            HttpServer server = new HttpServer(GlobalConfiguration.Configuration);

            GlobalConfiguration.Configuration.Routes.MapODataServiceRoute(
                "ODataRoute",
                "odata",
                EdmBuilder.GetEdm <Northwind>(), //builder.GetEdmModel(), //GetEdmModel(new Northwind()),
                new DefaultODataPathHandler()
            {
            },
                ODataRoutingConventions.CreateDefault(),
                new DefaultODataBatchHandler(server)
            {
                ODataRouteName = "ODataRoute"
            });

            //GlobalConfiguration.Configuration.Routes.MapHttpBatchRoute("batch", )
        }
Exemplo n.º 8
0
        public static void Register(HttpConfiguration config)
        {
#if !ODATA_MODEL_BUILDER
            config.Routes.MapODataRoute(
                routeName: "NorthwindIB_ODATA",
                routePrefix: "NorthwindIB_odata",
                model: EdmBuilder.GetEdm <NorthwindIBContext_Aliased>(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            var billingModel = EdmBuilder.GetEdm <InheritanceContext>();
            config.Routes.MapODataRoute(
                routeName: "BillingInheritance_ODATA",
                routePrefix: "BillingInheritance_odata",
                model: billingModel,
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            var produceModel = EdmBuilder.GetEdm <ProduceTPHContext>();
            config.Routes.MapODataRoute(
                routeName: "ProduceInheritance_ODATA",
                routePrefix: "ProduceInheritance_odata",
                model: produceModel,
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );
#else
            // If using ODataConventionModelBuilder
            var builder = new ODataConventionModelBuilder();
            builder.EntitySet <Product>("Products");
            builder.EntitySet <Customer>("Customers");
            builder.EntitySet <Employee>("Employees");
            builder.EntitySet <Order>("Orders");
            builder.EntitySet <OrderDetail>("OrderDetails");
            builder.EntitySet <Category>("Categories");
            builder.EntitySet <Supplier>("Suppliers");
            builder.EntitySet <Region>("Regions");
            builder.EntitySet <Territory>("Territories");
            builder.EntitySet <User>("Users");
            builder.EntitySet <InternationalOrder>("InternationalOrders");
            builder.EntitySet <TimeLimit>("TimeLimits");
            builder.EntitySet <TimeGroup>("TimeGroups");
            builder.EntitySet <EmployeeTerritory>("EmployeeTerritories");
            builder.EntitySet <UserRole>("UserRoles");
            builder.EntitySet <Comment>("Comments");
            builder.EntitySet <Role>("Roles");

            config.Routes.MapODataRoute(
                routeName: "NorthwindIB_ODATA",
                routePrefix: "NorthwindIB_odata",
                model: builder.GetEdmModel(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            builder = new ODataConventionModelBuilder();
            builder.EntitySet <BillingDetailTPC>("BillingDetailTPCs");
            builder.EntitySet <BillingDetailTPH>("BillingDetailTPHs");
            builder.EntitySet <BillingDetailTPT>("BillingDetailTPTs");
            builder.EntitySet <BankAccountTPC>("BankAccountTPCs");
            builder.EntitySet <BankAccountTPH>("BankAccountTPHs");
            builder.EntitySet <BankAccountTPT>("BankAccountTPTs");
            builder.EntitySet <AccountType>("AccountTypes");
            builder.EntitySet <DepositTPC>("DepositTPCs");
            builder.EntitySet <DepositTPH>("DepositTPHs");
            builder.EntitySet <DepositTPT>("DepositTPTs");
            config.Routes.MapODataRoute(
                routeName: "BillingInheritance_ODATA",
                routePrefix: "BillingInheritance_odata",
                model: builder.GetEdmModel(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            builder = new ODataConventionModelBuilder();
            builder.EntitySet <ItemOfProduce>("ItemsOfProduce");
            builder.EntitySet <Fruit>("Fruits");
            config.Routes.MapODataRoute(
                routeName: "ProduceInheritance_ODATA",
                routePrefix: "ProduceInheritance_odata",
                model: builder.GetEdmModel(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );
#endif

            // For handling the reset route
            config.Routes.MapHttpRoute(
                name: "SampleApi",
                routeTemplate: "breezeTests/breeze/{controller}/{action}"
                );
        }
Exemplo n.º 9
0
 public static IEdmModel GetBackboneEdm()
 {
     return(EdmBuilder.GetEdm <BackboneContext>());
 }
        public static void Register(HttpConfiguration config)
        {
#if !ODATA_MODEL_BUILDER
            config.Routes.MapODataRoute(
                routeName: "NorthwindIB_ODATA",
                routePrefix: "NorthwindIB_odata",
                model: EdmBuilder.GetEdm <NorthwindIBContext_Aliased>(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            var billingModel = EdmBuilder.GetEdm <InheritanceContext>();
            config.Routes.MapODataRoute(
                routeName: "BillingInheritance_ODATA",
                routePrefix: "BillingInheritance_odata",
                model: billingModel,
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            var produceModel = EdmBuilder.GetEdm <ProduceTPHContext>();
            config.Routes.MapODataRoute(
                routeName: "ProduceInheritance_ODATA",
                routePrefix: "ProduceInheritance_odata",
                model: produceModel,
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );
#else
            // If using ODataConventionModelBuilder
            var builder = new ODataConventionModelBuilder();

            var productType = builder.EntityType <Product>();
            productType.Ignore(t => t.DiscontinuedDate);
            productType.Property(t => t.OData4DiscontinuedDate).Name = "DiscontinuedDate";
            builder.EntitySet <Product>("Products");


            builder.EntitySet <Customer>("Customers");

            var empType = builder.EntityType <Employee>();
            empType.Ignore(t => t.BirthDate);
            empType.Property(t => t.OData4BirthDate).Name = "BirthDate";
            empType.Ignore(t => t.HireDate);
            empType.Property(t => t.OData4HireDate).Name = "HireDate";
            //var x = empType.HasMany(t => t.Orders).
            //builder.EntitySet<Employee>("Employees");

            var orderType = builder.EntityType <Order>();
            orderType.Ignore(t => t.OrderDate);
            orderType.Property(t => t.OData4OrderDate).Name = "OrderDate";
            orderType.Ignore(t => t.RequiredDate);
            orderType.Property(t => t.OData4RequiredDate).Name = "RequiredDate";
            orderType.Ignore(t => t.ShippedDate);
            orderType.Property(t => t.OData4ShippedDate).Name = "ShippedDate";
            builder.EntitySet <Order>("Orders");

            builder.EntitySet <OrderDetail>("OrderDetails");
            builder.EntitySet <Category>("Categories");
            builder.EntitySet <Supplier>("Suppliers");
            builder.EntitySet <Region>("Regions");
            builder.EntitySet <Territory>("Territories");

            var userType = builder.EntityType <User>();
            userType.Ignore(t => t.CreatedDate);
            userType.Property(t => t.OData4CreatedDate).Name = "CreatedDate";
            userType.Ignore(t => t.ModifiedDate);
            userType.Property(t => t.OData4ModifiedDate).Name = "ModifiedDate";
            builder.EntitySet <User>("Users");

            builder.EntitySet <InternationalOrder>("InternationalOrders");
            builder.EntitySet <TimeLimit>("TimeLimits");
            builder.EntitySet <TimeGroup>("TimeGroups");
            builder.EntitySet <EmployeeTerritory>("EmployeeTerritories");
            builder.EntitySet <UserRole>("UserRoles");

            var commentType = builder.EntityType <Comment>();
            commentType.Ignore(t => t.CreatedOn);
            commentType.Property(t => t.OData4CreatedOn).Name = "CreatedOn";
            builder.EntitySet <Comment>("Comments");

            // builder.EntitySet<Role>("Roles");

            config.MapODataServiceRoute(
                routeName: "NorthwindIB_ODATA",
                routePrefix: "NorthwindIB_odata",
                model: builder.GetEdmModel(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );

            //builder = new ODataConventionModelBuilder();

            ////var bdType = builder.EntityType<IBillingDetail>();
            ////bdType.Ignore(t => t.CreatedAt);
            ////builder.EntitySet<IBillingDetail>("IBillingDetails");

            //// BillingDetail
            //var bdTPCType = builder.EntityType<BillingDetailTPC>();
            //bdTPCType.Ignore(t => t.CreatedAt);
            //bdTPCType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<BillingDetailTPC>("BillingDetailTPCs");

            //var bdTPHType = builder.EntityType<BillingDetailTPH>();
            //bdTPHType.Ignore(t => t.CreatedAt);
            //bdTPHType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<BillingDetailTPH>("BillingDetailTPHs");

            //var bdTPTType = builder.EntityType<BillingDetailTPT>();
            //bdTPTType.Ignore(t => t.CreatedAt);
            //bdTPTType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<BillingDetailTPT>("BillingDetailTPTs");
            //// BankAccount
            //var baTPCType = builder.EntityType<BankAccountTPC>();
            //baTPCType.Ignore(t => t.CreatedAt);
            //baTPCType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<BankAccountTPC>("BankAccountTPCs");

            //var baTPHType = builder.EntityType<BankAccountTPH>();
            //baTPHType.Ignore(t => t.CreatedAt);
            //baTPHType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<BankAccountTPH>("BankAccountTPHs");

            //var baTPTType = builder.EntityType<BankAccountTPT>();
            //baTPTType.Ignore(t => t.CreatedAt);
            //baTPTType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<BankAccountTPT>("BankAccountTPTs");
            //// CreditCard
            //var ccTPCType = builder.EntityType<CreditCardTPC>();
            //ccTPCType.Ignore(t => t.CreatedAt);
            //ccTPCType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<CreditCardTPC>("CreditCardTPCs");

            //var ccTPHType = builder.EntityType<CreditCardTPH>();
            //ccTPHType.Ignore(t => t.CreatedAt);
            //ccTPHType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<CreditCardTPH>("CreditCardTPHs");

            //var ccTPTType = builder.EntityType<CreditCardTPT>();
            //ccTPTType.Ignore(t => t.CreatedAt);
            //ccTPTType.Property(t => t.OData4CreatedAt).Name = "CreatedAt";
            //builder.EntitySet<CreditCardTPT>("CreditCardTPTs");
            //// Deposit
            //var depositTPCType = builder.EntityType<DepositTPC>();
            //depositTPCType.Ignore(t => t.Deposited);
            //depositTPCType.Property(t => t.OData4Deposited).Name = "Deposited";
            //depositTPCType.HasRequired(t => t.BankAccount).AddedExplicitly = true;
            //builder.EntitySet<DepositTPC>("DepositTPCs");

            //var depositTPHType = builder.EntityType<DepositTPH>();
            //depositTPHType.Ignore(t => t.Deposited);
            //depositTPHType.Property(t => t.OData4Deposited).Name = "Deposited";

            //builder.EntitySet<DepositTPH>("DepositTPHs");

            //var depositTPTType = builder.EntityType<DepositTPT>();
            //depositTPTType.Ignore(t => t.Deposited);
            //depositTPTType.Property(t => t.OData4Deposited).Name = "Deposited";
            //builder.EntitySet<DepositTPT>("DepositTPTs");
            //// AccountType
            //builder.EntitySet<AccountType>("AccountTypes");

            //config.MapODataServiceRoute(
            //  routeName: "BillingInheritance_ODATA",
            //  routePrefix: "BillingInheritance_odata",
            //  model: builder.GetEdmModel(),
            //  batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
            //);

            builder = new ODataConventionModelBuilder();
            builder.EntitySet <ItemOfProduce>("ItemsOfProduce");
            builder.EntitySet <Fruit>("Fruits");
            config.MapODataServiceRoute(
                routeName: "ProduceInheritance_ODATA",
                routePrefix: "ProduceInheritance_odata",
                model: builder.GetEdmModel(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer)
                );
#endif
        }
Exemplo n.º 11
0
 public static IEdmModel GetWealthEconomyContextEdm()
 {
     return(EdmBuilder.GetEdm <WealthEconomyContext>());
 }