Sorting OData feeds by their title

Let’s say you’re browsing the Netflix OData catalog, and you’d like to sort the feed entries by their title. You type$orderby=title into your browser, but you get this error message back.

No property ‘title’ exists in type ‘NetflixCatalog.Services.Genre’ at position 0.

What went wrong? If you look at the payload for all genres, you’ll see the title there. But that’s the title ATOM element; if you want to refer to a property of genres, you need to use the property name from the model.

<title type=”text”>20th Century Period Pieces</title>
  <name />
<link rel=”edit” title=”Genre” href=”Genres(’20th%20Century%20Period%20Pieces’)” />
 href=”Genres(’20th%20Century%20Period%20Pieces’)/CatalogTitles” />
<category term=”NetflixModel.Genre
 scheme=”” />
<content type=”application/xml”>
    <d:Name>20th Century Period Pieces</d:Name>

So if you run$orderby=Name, the response is successful.

Of course you don’t have to look at data to figure this out. If you look at the metadata for the service, exposed at$metadata, you’ll see that the mapping is explicitly defined.

<EntityType Name=”Genre“>
  <PropertyRef Name=”Name” />
 <Property Name=”Name” Type=”Edm.String”
  Nullable=”false” MaxLength=”50″ Unicode=”false”
  m:FC_TargetPath=”SyndicationTitle” />
 <NavigationProperty Name=”CatalogTitles”
  FromRole=”Genres” ToRole=”CatalogTitles” />


Update: added missing error message.

Comments (0)

Skip to main content