{"id":393,"date":"2014-03-12T23:57:00","date_gmt":"2014-03-12T23:57:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/odatateam\/2014\/03\/12\/tutorial-sample-using-parameter-alias-to-simplify-the-odata-url\/"},"modified":"2020-01-07T07:43:03","modified_gmt":"2020-01-07T14:43:03","slug":"tutorial-sample-using-parameter-alias-to-simplify-the-odata-url","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/odata\/tutorial-sample-using-parameter-alias-to-simplify-the-odata-url\/","title":{"rendered":"[Tutorial &amp; Sample] Using Parameter Alias to simplify the OData URL"},"content":{"rendered":"<p>Are you suffering from typing complex parameter values in URL? Or even make it worse you need to type it more than once?<\/p>\n<p>To solve this problem, now Microsoft.OData.Core.dll 6.0 supports parameter alias in request URL\uff0c such as: ~\/People?$filter=LastName eq @name and contains(Description, @name)&amp;@name=\u2019Bob\u2019<\/p>\n<p>It is implemented by introducing a new class: ParameterAliasNode and its base class is SingleValueNode. The alias (@name) is parsed into a ParameterAliasNode.<\/p>\n<p>Note: This blog assumes that you have writing ODL server side code experience.<\/p>\n<p>But how to leverage this feature? Just 3 steps:<\/p>\n<p>1. Create an instance of ODataUriParser as normal:<\/p>\n<p><script type=\"text\/javascript\" src=\"https:\/\/gist.github.com\/tanjinfu\/9522869.js\"><\/script><\/p>\n<p>2. Update the node visitor to support ParameterAlliasNode:<\/p>\n<p><script type=\"text\/javascript\" src=\"https:\/\/gist.github.com\/tanjinfu\/9523053.js\"><\/script><\/p>\n<p>3. Call the visitor to translate the node tree into expression:<\/p>\n<p><script type=\"text\/javascript\" src=\"https:\/\/gist.github.com\/tanjinfu\/9523066.js\"><\/script><\/p>\n<p>Then execute the Linq Express as normal, that\u2019s it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you suffering from typing complex parameter values in URL? Or even make it worse you need to type it more than once? To solve this problem, now Microsoft.OData.Core.dll 6.0 supports parameter alias in request URL\uff0c such as: ~\/People?$filter=LastName eq @name and contains(Description, @name)&amp;@name=\u2019Bob\u2019 It is implemented by introducing a new class: ParameterAliasNode and its [&hellip;]<\/p>\n","protected":false},"author":525,"featured_media":3253,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-odata"],"acf":[],"blog_post_summary":"<p>Are you suffering from typing complex parameter values in URL? Or even make it worse you need to type it more than once? To solve this problem, now Microsoft.OData.Core.dll 6.0 supports parameter alias in request URL\uff0c such as: ~\/People?$filter=LastName eq @name and contains(Description, @name)&amp;@name=\u2019Bob\u2019 It is implemented by introducing a new class: ParameterAliasNode and its [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/users\/525"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/comments?post=393"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/media\/3253"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/media?parent=393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/categories?post=393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/tags?post=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}