Created
April 18, 2013 14:36
-
-
Save mahizsas/5413213 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*////////////////////////////////////////////////////////////////////////////////////// | |
| ////// Autogenerated by JaySvcUtil.exe http://JayData.org for more info ///////// | |
| ////// oData V3 ///////// | |
| //////////////////////////////////////////////////////////////////////////////////////*/ | |
| (function(global, $data, undefined) { | |
| $data.Entity.extend('Test.Testing.Models.ProductionOrder', { | |
| 'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'required':true }, | |
| 'OrderNr': { 'type':'Edm.Int32','nullable':false,'required':true }, | |
| 'OrderLine': { 'type':'Edm.Int32','nullable':false,'required':true } | |
| }); | |
| $data.EntityContext.extend('Default.Container', { | |
| 'ProductionOrders': { type: $data.EntitySet, elementType: Test.Testing.Models.ProductionOrder } | |
| }); | |
| $data.generatedContexts = $data.generatedContexts || []; | |
| $data.generatedContexts.push(Default.Container); | |
| /*Context Instance*/ | |
| Default.context = new Default.Container( { name:'oData', oDataServiceHost: 'http://localhost:52132/api' }); | |
| })(window, $data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"> | |
| <edmx:DataServices m:DataServiceVersion="1.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> | |
| <Schema Namespace="VFP.Mes.Models" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"> | |
| <EntityType Name="ProductionOrder"> | |
| <Key> | |
| <PropertyRef Name="Id" /> | |
| </Key> | |
| <Property Name="Id" Type="Edm.Int32" Nullable="false" /> | |
| <Property Name="OrderNr" Type="Edm.Int32" Nullable="false" /> | |
| <Property Name="OrderLine" Type="Edm.Int32" Nullable="false" /> | |
| </EntityType> | |
| </Schema> | |
| <Schema Namespace="Default" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"> | |
| <EntityContainer Name="Container"> | |
| <EntitySet Name="ProductionOrders" EntityType="VFP.Mes.Models.ProductionOrder" /> | |
| </EntityContainer> | |
| </Schema> | |
| </edmx:DataServices> | |
| </edmx:Edmx> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class WebApiConfig | |
| { | |
| public static void Register(HttpConfiguration config) | |
| { | |
| // Register an Action selector that can include template parameters in the name | |
| config.Services.Replace(typeof(IHttpActionSelector), new ODataActionSelector()); | |
| var model = GetEdmModel(); | |
| var odataFormatter = new ODataMediaTypeFormatter(model); | |
| config.Formatters.Clear(); | |
| config.Formatters.Insert(0, odataFormatter); | |
| // Metadata routes to support $metadata and code generation in the WCF Data Service client. | |
| config.Routes.MapHttpRoute(ODataRouteNames.Metadata, "api/$metadata", new { Controller = "ODataMetadata", Action = "GetMetadata" }); | |
| config.Routes.MapHttpRoute(ODataRouteNames.ServiceDocument, "api/", new { Controller = "ODataMetadata", Action = "GetServiceDocument" }); | |
| // Relationship routes (notice the parameters is {type}Id not id, this avoids colliding with GetById(id)). | |
| config.Routes.MapHttpRoute(ODataRouteNames.PropertyNavigation, "api/{controller}({parentId})/{navigationProperty}"); | |
| // Route for manipulating links. | |
| config.Routes.MapHttpRoute(ODataRouteNames.Link, "api/{controller}({id})/$links/{navigationProperty}"); | |
| // Routes for urls both producing and handling urls like ~/Product(1), ~/Products() and ~/Products | |
| config.Routes.MapHttpRoute(ODataRouteNames.GetById, "api/{controller}({id})"); | |
| config.Routes.MapHttpRoute(ODataRouteNames.DefaultWithParentheses, "api/{controller}()"); | |
| config.Routes.MapHttpRoute(ODataRouteNames.Default, "api/{controller}"); | |
| } | |
| private static IEdmModel GetEdmModel() | |
| { | |
| ODataModelBuilder modelBuilder = new ODataConventionModelBuilder(); | |
| modelBuilder.EntitySet<ProductionOrder>("ProductionOrders"); | |
| return modelBuilder.GetEdmModel(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment