{"id":563,"date":"2012-12-07T14:38:11","date_gmt":"2012-12-07T14:38:11","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/odatateam\/2012\/12\/07\/wcf-data-services-5-2-0-rc1-prerelease\/"},"modified":"2012-12-07T14:38:11","modified_gmt":"2012-12-07T14:38:11","slug":"wcf-data-services-5-2-0-rc1-prerelease","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/odata\/wcf-data-services-5-2-0-rc1-prerelease\/","title":{"rendered":"WCF Data Services 5.2.0-rc1 Prerelease"},"content":{"rendered":"<p>A couple of days ago we posted a <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Data.Services\/5.2.0-rc1\" target=\"_blank\">new set of NuGet packages<\/a> and today we posted a <a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=35840\" target=\"_blank\">new tools installer<\/a> for WCF Data Services 5.2.0-rc1. This prerelease integrates the UriParser from ODataLib Contrib and fixes a few bugs.<\/p>\n<h4>What is in the prerelease<\/h4>\n<p>This prerelease contains the following noteworthy bug fixes:<\/p>\n<ul>\n<li>Fixes an issue where code gen for exceedingly large models would cause VS to crash<\/li>\n<li>Provides a better error message when the service model exposes enum properties<\/li>\n<li>Fixes an issue where <font face=\"Courier New\">IgnoreMissingProperties<\/font> did not work properly with the new JSON format<\/li>\n<li>Fixes an issue where an Atom response is unable to be read if the client is set to use the new JSON format<\/li>\n<\/ul>\n<h4>URI Parser<\/h4>\n<p>In this release ODataLib now provides a way to parse filter and orderby expressions into a metadata-bound abstract syntax tree (AST). This functionality is typically intended to be consumed by higher level libraries such as WCF Data Services and Web API.<\/p>\n<p>To parse a filter expression, use the following method on the new class <font color=\"#4bacc6\" face=\"Courier New\">ODataUriParser<\/font>: <\/p>\n<p><font face=\"Courier New\"><font color=\"#0000ff\">public<\/font> <font color=\"#0000ff\">static<\/font> <font color=\"#4bacc6\">FilterClause<\/font> <font color=\"#4bacc6\">ParseFilter<\/font>(      <br \/>&#160;&#160;&#160; <font color=\"#0000ff\">string<\/font> filter,      <br \/>&#160;&#160;&#160; <font color=\"#4bacc6\">IEdmModel<\/font> model,      <br \/>&#160;&#160;&#160; <font color=\"#4bacc6\">IEdmType<\/font> elementType,      <br \/>&#160;&#160;&#160; <font color=\"#4bacc6\">IEdmEntitySet<\/font> entitySet)<\/font><\/p>\n<p>The <font color=\"#4bacc6\" face=\"Courier New\">ParseFilter<\/font> method returns a <font color=\"#4bacc6\" face=\"Courier New\">FilterClause<\/font> object. The <font color=\"#000000\" face=\"Courier New\">Expression<\/font> property on the <font color=\"#4bacc6\" face=\"Courier New\">FilterClause<\/font> contains the root node of the AST that represents the filter expression. In order to walk the AST, use the Visitor pattern to handle an arbitrary <font color=\"#4bacc6\" face=\"Courier New\">QueryNode<\/font> by examining the <font color=\"#4bacc6\" face=\"Courier New\">Kind<\/font> property, and then casting accordingly. For instance:<\/p>\n<p><font face=\"Courier New\"><font color=\"#0000ff\">switch<\/font> (node.Kind)      <br \/>{      <br \/>&#160;&#160;&#160; <font color=\"#0000ff\">case<\/font> <font color=\"#4bacc6\">QueryNodeKind<\/font>.BinaryOperator:      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\">return<\/font> Visit((<font color=\"#4bacc6\">BinaryOperatorNode<\/font>)node);       <br \/>&#160;&#160;&#160; <font color=\"#0000ff\">case<\/font> <font color=\"#4bacc6\">QueryNodeKind<\/font>.UnaryOperator:       <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\">return<\/font> Visit((<font color=\"#4bacc6\">UnaryOperatorNode<\/font>)node);       <br \/>&#160;&#160;&#160; <font color=\"#0000ff\">case<\/font> <font color=\"#4bacc6\">QueryNodeKind<\/font>.SingleValuePropertyAccess:       <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\">return<\/font> Visit((<font color=\"#4bacc6\">SingleValuePropertyAccessNode<\/font>)node);       <br \/><font color=\"#008000\">&#160;&#160;&#160;&#160; \/\/ And so on&#8230; <\/font><font color=\"#a5a5a5\">       <br \/><\/font>}<\/font> <\/p>\n<p>Let\u2019s say the filter string was <font color=\"#c0504d\" face=\"Courier New\">&quot;Name eq &#8216;Bob&#8217;&quot;<\/font>, and <font color=\"#000000\" face=\"Courier New\">Name<\/font> is a property on the <font face=\"Courier New\">elementType<\/font> provided to <font color=\"#4bacc6\" face=\"Courier New\">ParseFilter<\/font>.&#160; This expression is represented by a <font color=\"#4bacc6\" face=\"Courier New\">BinaryOperatorNode<\/font>. The <font color=\"#4bacc6\" face=\"Courier New\">BinaryOperatorNode<\/font> has a <font face=\"Courier New\">Left<\/font> expression, which is a <font color=\"#4bacc6\" face=\"Courier New\">SingleValuePropertyAccessNode<\/font>, capturing the <font face=\"Courier New\">Name<\/font> property, and a <font face=\"Courier New\">Right<\/font> expression, which is a <font color=\"#4bacc6\" face=\"Courier New\">ConstantNode<\/font>, capturing the string literal <font color=\"#c0504d\" face=\"Courier New\">&#8216;Bob&#8217;<\/font>.&#160; <\/p>\n<p>To parse an orderby expression, use <font face=\"Courier New\"><font color=\"#4bacc6\">ODataUriParser<\/font>.<font color=\"#4bacc6\">ParseOrderBy<\/font><\/font>. This method is very similar to <font color=\"#4bacc6\" face=\"Courier New\">ParseFilter<\/font>. The resulting <font color=\"#4bacc6\" face=\"Courier New\">OrderByClause<\/font> also has an <font face=\"Courier New\">Expression<\/font> property, which is an AST just like <font color=\"#4bacc6\" face=\"Courier New\">FilterClause<\/font>. Since an $orderby system query option can specify more than one ordering expression, there is a <font face=\"Courier New\">ThenBy<\/font> property on <font color=\"#4bacc6\" face=\"Courier New\">OrderByClause<\/font> that points to the next <font color=\"#4bacc6\" face=\"Courier New\">OrderByClause<\/font>. So in essence, you get a linked list of <font color=\"#4bacc6\" face=\"Courier New\">OrderByClause<\/font> objects. For example, the string <font color=\"#c0504d\" face=\"Courier New\">&quot;Name asc, ShoeSize desc&quot;<\/font> would result in an <font color=\"#4bacc6\" face=\"Courier New\">OrderByClause<\/font> with an <font face=\"Courier New\">Expression<\/font> capturing the <font face=\"Courier New\">Name<\/font> property, and a <font face=\"Courier New\">ThenBy<\/font> property pointing to another <font color=\"#4bacc6\" face=\"Courier New\">OrderByClause<\/font> capturing the intent to order by the <font face=\"Courier New\">ShoeSize<\/font> in descending order.<\/p>\n<p>For a more detailed write-up on filter and orderby parsing, read <a href=\"http:\/\/blogs.msdn.com\/b\/alexj\/archive\/2012\/12\/06\/parsing-filter-and-orderby-using-the-odatauriparser.aspx\" target=\"_blank\">this blog post<\/a>.<\/p>\n<h4>Feedback Please<\/h4>\n<p>We\u2019d love to hear how well this release works for your service. Even if you don\u2019t need the URI Parser functionality, please consider trying these new bits and providing us with feedback whether everything goes perfectly or you run into problems. As always, please feel free to leave a comment below or e-mail me directly at <a href=\"mailto:mastaffo@microsoft.com\">mastaffo@microsoft.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of days ago we posted a new set of NuGet packages and today we posted a new tools installer for WCF Data Services 5.2.0-rc1. This prerelease integrates the UriParser from ODataLib Contrib and fixes a few bugs. What is in the prerelease This prerelease contains the following noteworthy bug fixes: Fixes an issue [&hellip;]<\/p>\n","protected":false},"author":512,"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-563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-odata"],"acf":[],"blog_post_summary":"<p>A couple of days ago we posted a new set of NuGet packages and today we posted a new tools installer for WCF Data Services 5.2.0-rc1. This prerelease integrates the UriParser from ODataLib Contrib and fixes a few bugs. What is in the prerelease This prerelease contains the following noteworthy bug fixes: Fixes an issue [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/563","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\/512"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/comments?post=563"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/563\/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=563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/categories?post=563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/tags?post=563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}