{"id":1063,"date":"2010-11-15T17:05:42","date_gmt":"2010-11-15T17:05:42","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/odatateam\/2010\/11\/15\/additional-feed-customization-support\/"},"modified":"2010-11-15T17:05:42","modified_gmt":"2010-11-15T17:05:42","slug":"additional-feed-customization-support","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/odata\/additional-feed-customization-support\/","title":{"rendered":"Additional Feed Customization Support"},"content":{"rendered":"<h3><span><span>1.<span>&#160;&#160;&#160;&#160; <\/span><\/span><\/span>Problem: <\/h3>\n<h2 style=\"text-indent: -0.25in;margin-left: 0.5in\"><span><span><\/span><\/span>    <\/p>\n<\/h2>\n<p class=\"MsoNoSpacing\">In the previous version, WCF Data Services introduced the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ee373839.aspx\"><font color=\"#0000ff\">feed customization<\/font><\/a> feature. This feature enabled users to map properties to certain elements in the Atom document. As an example, users could map a name property to the Atom title element. This is especially useful for generic feed readers which may not know how to interpret the properties in the content element but understand other Atom elements. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">The <a href=\"http:\/\/www.odata.org\"><font color=\"#0000ff\">OData<\/font><\/a> protocol, and therefore our implementation, did not allow users to map to the repeating Atom link and category elements. In addition, users never had the ability to map properties based on a condition. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<h3><span><span>2.<span>&#160;&#160;&#160;&#160; <\/span><\/span><\/span>Design: <\/h3>\n<h2 style=\"text-indent: -0.25in;margin-left: 0.5in\"><span><span><\/span><\/span>    <\/p>\n<\/h2>\n<p class=\"MsoNoSpacing\">We have extended the set of Atom elements that can be mapped and introduced a new feature known as Conditional Entity Property Mapping (EPM) to solve the issues discussed above. This new feature includes 2 parts. First, users can specify standard, unconditional mapping to Atom link and category elements. Second is the ability to map to the Atom link and category elements based on a condition. For example, only apply the mapping when the link element\u2019s rel attribute (denoted as link\/@rel) has a value equal to \u201chttp:\/\/MyValue\u201d. We\u2019ll get into some specifics later on in this post but the condition only applies to the link\/@rel and category\/@scheme attributes. Conditional mapping is not supported for other Atom or Custom feed elements at this time. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<h3><span><span>3.<span>&#160;&#160;&#160;&#160; <\/span><\/span><\/span>Understanding the Feature: <\/h3>\n<h2 style=\"text-indent: -0.25in;margin-left: 0.5in\"><span><span><\/span><\/span>    <\/p>\n<\/h2>\n<h4><span><span>3.1&#160; <\/span><\/span>Extending Feed Customizations (Unconditional Mappings): <\/h4>\n<h3 style=\"text-indent: -0.25in;margin-left: 0.5in\"><span><span><\/span><\/span>    <\/p>\n<\/h3>\n<h3>\n<p>&#160;<\/p>\n<\/h3>\n<p class=\"MsoNoSpacing\">Let\u2019s first start with unconditional mapping to Atom link and category elements. This is the same process as the feed customization introduced in the previous version. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">Mappings are described on classes through the EntityPropertyMappingAttribute. This attribute is present on generated client classes to describe the mapping, and is used to define mappings exposed by the reflection provider: <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span>public<\/span><span> EntityPropertyMappingAttribute( <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><span>string<\/span><span> sourcePath, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>SyndicationItemProperty targetSyndicationItem, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>SyndicationTextContentKind targetTextContentKind, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><span>bool<\/span><span> keepInContent <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 9pt\" class=\"MsoNormal\"><span>) <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">We updated the SyndicationItemProperty enum to include the link and category element\u2019s attributes. The full list of updates can be found in the table below. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">A service describes mapping through the CSDL exposed by its $metadata endpoint. These same CSDL annotations are used to describe mappings to the<span>&#160; <\/span>Entity Framework (EF) provider. The set of valid values for FC_TargetPath has been extended to include the new link and category attributes: <\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span>&lt;Property Name=&quot;Term&quot; Type=&quot;String&quot; Nullable=&quot;false&quot; <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>MaxLength=&quot;40&quot; Unicode=&quot;true&quot; FixedLength=&quot;false&quot; <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>m:FC_TargetPath=<b>&quot;SyndicationCategoryTerm&quot;<\/b> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>m:FC_ContentKind=&quot;text&quot; <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>m:FC_KeepInContent=&quot;false&quot; <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 9pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160; <\/span>\/&gt; <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">The additions to both the SyndicationItemProperty enum and FC_TargetPath attribute can be found in the table below: <\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p><b>EntityPropertyMapping<\/b><\/p>\n<p><b>&#160;&#160;&#160; SyndicationItemProperty<\/b><\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p><b>CSDL<\/b><\/p>\n<p><b>&#160;&#160;&#160; FC_TargetPath<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; LinkHref<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationLinkHref<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; LinkRel<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationLinkRel<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; LinkType<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationLinkType<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; LinkHrefLang<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationLinkHrefLang<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; LinkTitle<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationLinkTitle<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; LinkLength<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationLinkLength<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; CategoryTerm<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationCategoryTerm<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; CategoryScheme <\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationCategoryScheme<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; CategoryLabel<\/p>\n<\/td>\n<td valign=\"top\" width=\"295\">\n<p>&#160;&#160;&#160; SyndicationCategoryLabel<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span><\/span><\/p>\n<p><span>In the mapping described above, the \u201cTerm\u201d property is mapped to \u201cSyndicationCategoryTerm\u201d and the property is also kept in the content element. Assuming the value of the \u201cTerm\u201d property is \u201cMyTermValue\u201d and no other mappings exist, that section of the entry would look something like: <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"margin-bottom: 0pt\" class=\"MsoNormal\"><span><span class=\"m1\"><\/span><\/span><span style=\"color: blue\">\u2026<\/span><\/p>\n<p style=\"margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"color: blue\"><\/span><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">category<\/span><span> <span style=\"color: #990000\">term<\/span><span style=\"color: blue\">=&quot;<\/span><b>MyTermValue<\/b><span style=\"color: blue\">&quot;<\/span><span style=\"color: blue\"> \/&gt;<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0pt\" class=\"MsoNormal\"><span><span style=\"color: blue\"><\/span><\/span><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">content type<\/span><span><span style=\"color: blue\">=&quot;<\/span><b>application\/xml<\/b><span style=\"color: blue\">&quot;<\/span><span style=\"color: blue\">&gt;<\/span><\/span><\/p>\n<p style=\"text-indent: 0.5in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">m:properties<\/span><span><span style=\"color: blue\">&gt;<\/span><\/span><\/p>\n<p style=\"text-indent: 0.5in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">\u2026<\/span><\/p>\n<p style=\"text-indent: 0.5in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;\/<\/span><span style=\"color: #990000\">m:properties<\/span><span><span style=\"color: blue\">&gt;<\/span><\/span><\/p>\n<p class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;\/<\/span><span style=\"color: #990000\">content<\/span><span><span style=\"color: blue\">&gt;<\/span><\/span><\/p>\n<p class=\"MsoNoSpacing\"><span>When mapping to the Atom link element, there is an additional rule to consider. Since an empty link\/@rel value is interpreted as \u201calternate\u201d (<\/span><a href=\"http:\/\/tools.ietf.org\/html\/rfc4287#section-4.2.7\"><span><font color=\"#0000ff\">RFC4287<\/font><\/span><\/a><span>), and the OData protocol does not allow mapping link\/@rel to simple identifiers (eg. edit, self, alternate, \u2026), when defining unconditional mapping to the link element we must specify a mapping to link\/@rel: <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">[<span style=\"color: #2b91af\">EntityPropertyMappingAttribute<\/span>( <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;text-indent: 0.5in;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: #a31515;font-size: 9.5pt\">&quot;MyHref&quot;<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin: 0in 0in 0pt 0.5in\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: #2b91af;font-size: 9.5pt\">SyndicationItemProperty<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">.LinkHref, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin: 0in 0in 0pt 0.5in\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: #2b91af;font-size: 9.5pt\">SyndicationTextContentKind<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">.Plaintext, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin: 0in 0in 0pt 0.5in\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: blue;font-size: 9.5pt\">true<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">)] <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">[<span style=\"color: #2b91af\">EntityPropertyMappingAttribute<\/span>(<span style=\"color: #a31515\">&quot;MyRel&quot;<\/span>, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;text-indent: 0.5in;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: #2b91af;font-size: 9.5pt\">SyndicationItemProperty<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">.LinkRel, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin: 0in 0in 0pt 0.5in\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: #2b91af;font-size: 9.5pt\">SyndicationTextContentKind<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">.Plaintext, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin: 0in 0in 0pt 0.5in\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: blue;font-size: 9.5pt\">true<\/span><span style=\"font-family: consolas;font-size: 9.5pt\">)] <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">[<span style=\"color: #2b91af\">DataServiceKeyAttribute<\/span>(<span style=\"color: #a31515\">&quot;id&quot;<\/span>)] <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: blue;font-size: 9.5pt\">public<\/span><span style=\"font-family: consolas;font-size: 9.5pt\"> <span style=\"color: blue\">class<\/span> <span style=\"color: #2b91af\">Photos<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">{ <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span style=\"color: blue\">public<\/span> <span style=\"color: blue\">int<\/span> id { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span style=\"color: blue\">public<\/span> <span style=\"color: blue\">string<\/span> MyHref { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span style=\"color: blue\">public<\/span> <span style=\"color: blue\">string<\/span> MyRel { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">} <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<h4><span><span>3.2 <span>&#160;<\/span><\/span><\/span>New Conditional Entity Property Mappings: <\/h4>\n<h3 style=\"text-indent: -0.25in;margin-left: 0.5in\"><span><span><\/span><\/span>    <\/p>\n<\/h3>\n<p class=\"MsoNoSpacing\"><span><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">Now that we\u2019ve covered the extensions to feed customization mappings, let\u2019s look at the second part of this feature, conditional mapping. There are situations where a user may only want to map to Atom link and category elements when they satisfy a certain condition. For example, assume we have a model that contains a collection of photos. These photos may differ in their resolution (eg. Hi-res, low-res, thumbnail). It makes sense to map the resolution to a category element since it helps to distinguish the different photos. Conditions are useful here because there may be other category elements we don\u2019t care about. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">In order to use conditions in the mappings, we introduced a new EntityPropertyMappingAttribute constructor: <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span>public<\/span><span> EntityPropertyMappingAttribute( <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><span>string<\/span><span> sourcePath, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>SyndicationItemProperty targetSyndicationItem, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><span>bool<\/span><span> keepInContent, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>SyndicationCriteria criteria, <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><span>string<\/span><span> criteriaValue <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 9pt\" class=\"MsoNormal\"><span>) <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">Notice the addition of the criteria and criteraValue parameters. The SyndicationCriteria parameter is a new enum with values: <\/p>\n<\/p>\n<p style=\"text-indent: -0.25in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"font-family: symbol\"><span>\u00b7<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><\/span>LinkRel <\/p>\n<\/p>\n<p style=\"text-indent: -0.25in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"font-family: symbol\"><span>\u00b7<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><\/span>CategoryScheme <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">Similarly, we are introducing new CSDL attributes for FC_Criteria and FC_CriteriaValue. For FC_Criteria, the corresponding values are: <\/p>\n<\/p>\n<p style=\"text-indent: -0.25in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"font-family: symbol\"><span>\u00b7<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><\/span><span>SyndicationLinkRel<\/span> <\/p>\n<\/p>\n<p style=\"text-indent: -0.25in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"font-family: symbol\"><span>\u00b7<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><\/span><\/span><span>SyndicationCategoryScheme<\/span> <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span>The criteria indicates the attribute on which the condition exists. For example, if the criteria equals \u201cCategoryScheme\u201d, the condition would depend on the value of the category\/@scheme. <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span>The criteriaValue parameter specifies the value that must be matched in order for the mapping to apply. To make this clearer, let\u2019s look at the following example: <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;<\/span>[<span style=\"color: #2b91af\">EntityPropertyMappingAttribute<\/span>( <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #a31515\">&quot;Term&quot;<\/span>,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ sourcePath<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #2b91af\">SyndicationItemProperty<\/span>.CategoryTerm,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ targetPath<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: blue\">false<\/span>,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ keepInContent<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #2b91af\">SyndicationCriteria<\/span>.CategoryScheme,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ criteria<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span>&#160;&#160; <\/span><span style=\"color: #a31515\">&quot;http:\/\/foo.com\/MyPhotos&quot;<\/span>)]<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ criteriaValue<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">[<span style=\"color: #2b91af\">DataServiceKeyAttribute<\/span>(<span style=\"color: #a31515\">&quot;id&quot;<\/span>)] <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: blue;font-size: 9.5pt\">public<\/span><span style=\"font-family: consolas;font-size: 9.5pt\"> <span style=\"color: blue\">class<\/span> <span style=\"color: #2b91af\">Category<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">{ <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: blue;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span>public<\/span><span style=\"font-family: consolas;font-size: 9.5pt\"> <span style=\"color: blue\">int<\/span> id { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span style=\"color: blue\">public<\/span> <span style=\"color: blue\">string<\/span> Term { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span>} <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span>To understand what this mapping describes, we\u2019ll break it down into the serialization and deserialization steps. When serializing to a feed, the \u201cTerm\u201d property will be mapped to category\/@term with category\/@scheme equal to the criteriaValue, \u201chttp:\/\/foo.com\/MyPhotos\u201d. <span>&#160;<\/span>Assuming the \u201cTerm\u201d property has a value of \u201cMyTermValue\u201d, the mapping above would generate a feed like: <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span style=\"color: blue\"><\/span><\/p>\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">entry<\/span><span style=\"color: blue\">&gt; <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span style=\"color: blue\">\u2026<\/span><span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"text-indent: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">category<\/span><span> <span style=\"color: #990000\">term<\/span><span style=\"color: blue\">=&quot;<\/span><b>MyTermValue<\/b><span style=\"color: blue\">&quot;<\/span><span style=\"color: #990000\"> scheme<\/span><span style=\"color: blue\">=&quot;<\/span><b>http:\/\/foo.com\/MyPhotos<\/b><span style=\"color: blue\">&quot; \/&gt;<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"text-indent: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">content type<\/span><span><span style=\"color: blue\">=&quot;<\/span><b>application\/xml<\/b><span style=\"color: blue\">&quot;<\/span><span style=\"color: blue\">&gt;<\/span><\/span><\/p>\n<p style=\"text-indent: 0.5in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">&lt;<\/span><span style=\"color: #990000\">m:properties<\/span><span><span style=\"color: blue\">&gt;<\/span><\/span><\/p>\n<p style=\"text-indent: 0.5in;margin-left: 0.5in\" class=\"MsoNoSpacing\"><span style=\"color: blue\">\u2026<\/span><\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">For deserialization, if the entry has a category element where category\/@scheme equals \u201chttp:\/\/foo.com\/MyPhotos\u201d, the mapping will occur. All other category elements will be ignored by this mapping. It is important to know that, when the value of the attribute and criteraValue are compared, the comparison is for case insensitive, non-escaped, and equal string values. <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">To finish off the examples, here is a conditional mapping to the link element: <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">[<span style=\"color: #2b91af\">EntityPropertyMappingAttribute<\/span>( <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #a31515\">&quot;MyHref&quot;<\/span>,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ sourcePath<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #2b91af\">SyndicationItemProperty<\/span>.LinkHref,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span>&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ targetPath<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: blue\">false<\/span>,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span>&#160;<\/span><span style=\"color: green\">\/\/ keepInContent<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #2b91af\">SyndicationCriteria<\/span>.LinkRel,<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: green\">\/\/ criteria<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160;&#160;&#160; <\/span><span style=\"color: #a31515\">&quot;http:\/\/MyRelValue&quot;<\/span>)]<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span><span>&#160;<\/span><span style=\"color: green\">\/\/ criteriaValue <\/span><\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">[<span style=\"color: #2b91af\">DataServiceKeyAttribute<\/span>(<span style=\"color: #a31515\">&quot;id&quot;<\/span>)] <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;color: blue;font-size: 9.5pt\">public<\/span><span style=\"font-family: consolas;font-size: 9.5pt\"> <span style=\"color: blue\">class<\/span> <span style=\"color: #2b91af\">Photos<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\">{ <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span style=\"color: blue\">public<\/span> <span style=\"color: blue\">int<\/span> id { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p style=\"line-height: normal;margin-bottom: 0pt\" class=\"MsoNormal\"><span style=\"font-family: consolas;font-size: 9.5pt\"><span>&#160;&#160;&#160; <\/span><span style=\"color: blue\">public<\/span> <span style=\"color: blue\">string<\/span> MyHref { <span style=\"color: blue\">get<\/span>; <span style=\"color: blue\">set<\/span>; } <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">} <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">Notice how the condition is on link\/@rel. Since the criteriaValue is not a simple identifier, this mapping automatically satisfies the simple identifier rule described above. When serializing to a feed, this will look like: <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\u2026 <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\"><span style=\"color: blue;font-size: 10pt\">&lt;<\/span><span style=\"color: #990000;font-size: 10pt\">link<\/span><span style=\"font-size: 10pt\"> <span style=\"color: #990000\">href<\/span><span style=\"color: blue\">=&quot;<\/span><b>http:\/\/hrefValue.com\/<\/b><span style=\"color: blue\">&quot;<\/span><span style=\"color: #990000\"> rel<\/span><span style=\"color: blue\">=&quot;<\/span><b>http:\/\/MyRelValue<\/b><span style=\"color: blue\">&quot; \/&gt;<\/span> <\/span><\/p>\n<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\u2026 <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">To summarize, this new feature includes 2 parts. The first part extends Feed Customization to the Atom link and category elements. The second part introduces mapping based on conditions.&#160; <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">\n<p>&#160;<\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">Julian Lai <\/p>\n<\/p>\n<p class=\"MsoNoSpacing\">WCF Data Services, Program Manager <\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.&#160;&#160;&#160;&#160; Problem: In the previous version, WCF Data Services introduced the feed customization feature. This feature enabled users to map properties to certain elements in the Atom document. As an example, users could map a name property to the Atom title element. This is especially useful for generic feed readers which may not know how [&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-1063","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-odata"],"acf":[],"blog_post_summary":"<p>1.&#160;&#160;&#160;&#160; Problem: In the previous version, WCF Data Services introduced the feed customization feature. This feature enabled users to map properties to certain elements in the Atom document. As an example, users could map a name property to the Atom title element. This is especially useful for generic feed readers which may not know how [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/1063","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=1063"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/1063\/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=1063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/categories?post=1063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/tags?post=1063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}