Odata Query Options<\/strong><\/a><\/td>Meaning<\/strong><\/td><\/tr>$top = n<\/strong><\/td>Return the first nth data<\/strong><\/td><\/tr>$skip = n<\/strong><\/td>Skip the first nth data<\/strong><\/td><\/tr>$Orderby<\/strong><\/td>Return the data in ascending or descending or<\/strong><\/td><\/tr>$filter<\/strong><\/td>Return the data which satisfies the filter condition<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\nASP.NET FRAMEWORK<\/strong><\/p>\n\n\n\nDownload OData package<\/p>\n\n\n\n <\/figure>\n\n\n\nNow, we have to append WebApiConfig.cs<\/p>\n\n\n\n <\/figure>\n\n\n\nController must inherit ODataController class<\/p>\n\n\n\n <\/figure>\n\n\n\nThen for Web Api, add [EnableQuery] Attribute for the HTTP method<\/p>\n\n\n\n <\/figure>\n\n\n\nASP.NET CORE<\/strong><\/p>\n\n\n\nSame to ASP.NET FRAMEWORK, we have to download OData package firstly<\/p>\n\n\n\n <\/figure>\n\n\n\nThen add codes shown below<\/p>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\nLastly, remember to add [EnableQuery] Attribute prior to the HTTP method<\/p>\n\n\n\n <\/figure>\n\n\n\nOData Example<\/strong><\/p>\n\n\n\nThe following example will use Product class below<\/p>\n\n\n\n <\/figure>\n\n\n\nThen set the data for testing<\/p>\n\n\n\n <\/figure>\n\n\n\nAfter the execution of Visual Studio or any other IDE, enter the URL<\/p>\n\n\n\n <\/figure>\n\n\n\nYou then will see the result json like this.<\/p>\n\n\n\n <\/figure>\n\n\n\nOn the other hand, if you want to see both fields (Name and Price), you need to fix the URL<\/p>\n\n\n\n <\/figure>\n\n\n\nThe result will look like<\/p>\n\n\n\n <\/figure>\n\n\n\nSay you then have a new request, you want to see the price of the product list in the order from low to high, you just need to add $OrderBy semantics to the URL<\/p>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\nConclusion<\/strong><\/p>\n\n\n\nThe above example manifests the potential of OData. We just have to append query language to get the data structure we want. However for the other Restful API method, we may have to add and fix large segments of the original code written to achieve our goal. For the OData, we only need to add or change small part of code to allow OData work on either ASP.NET FRAMEWORK or ASP.NET CORE framework. Hence, OData is an useful and flexible standard to achieve Restful architecture.<\/p>\n","protected":false},"excerpt":{"rendered":"
OData Protocol (Open Data Protocol) was released by Microsoft in 2007. The current version has been upgraded to 4.0. Now OASIS (Organization for the Advancement of Structured Information Standards) has approved this protocol standard. OData is based on REST principle to offer HTTP CRUD service. This protocol also provides special query language expression to help […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[33],"tags":[],"class_list":["post-324","post","type-post","status-publish","format-standard","hentry","category-programming-2"],"yoast_head":"\n
OData Protocol - Who said turtle cannot fly<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n