{"id":230,"date":"2015-06-03T13:03:24","date_gmt":"2015-06-03T13:03:24","guid":{"rendered":"http:\/\/shivaprogramming.com\/blog\/?p=230"},"modified":"2016-06-04T04:03:32","modified_gmt":"2016-06-04T04:03:32","slug":"enabling-odata-queries-in-web-api","status":"publish","type":"post","link":"http:\/\/shivaprogramming.com\/blog\/enabling-odata-queries-in-web-api\/","title":{"rendered":"Enabling OData Queries in Web API"},"content":{"rendered":"<p>Enabling OData Queries in Web API<\/p>\n<p>Add EnableQuery Attribute (Action filter)<\/p>\n<p>Change the IEnumerable return type to IQueryable<\/p>\n<p>Add AsQueryable() to convert the IEnumerable to an IQueryable<\/p>\n<p>[EnableQuery()]<\/p>\n<p>public IQueryable&lt;Product&gt; Get()<\/p>\n<p>{<\/p>\n<p>var productRepository=new ProductRepository();<\/p>\n<p>return productRepositriy.Retrieve().AsQueryable();<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enabling OData Queries in Web API Add EnableQuery Attribute (Action filter) Change the IEnumerable return type to IQueryable Add AsQueryable() to convert the IEnumerable to an&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-230","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/posts\/230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/comments?post=230"}],"version-history":[{"count":3,"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions"}],"predecessor-version":[{"id":233,"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions\/233"}],"wp:attachment":[{"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/media?parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/categories?post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivaprogramming.com\/blog\/wp-json\/wp\/v2\/tags?post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}