The use case is the following: retrieve the 5 latest posts.
I am trying to get OData results sorted by a Custom Component Metadata date field, but the statement below breaks.
var pres = service.Components.OrderBy(c => c.CustomMetas[0].DateValue);
The error thrown is the following:
Error translating Linq expression to URI: The expression [10007].CustomMetas.get_Item[0].DateValue is not supported.
Obviously I can always sort the data after retrieving the results, however this shouldn't be done for this use case since there could be thousands of results and we would need to parse them, this is far from efficient.
---- EDIT ----
Thanks to Nickoli I got to get it working.
The information I am retrieving matches the following criteria:
- Components
- Filter by schema 468
- 5 entries
- Results sorted descending based on Custom Meta date field (ReleaseDate)
The URI looks like this:
http://domain/odata.svc/CustomMetas/?$expand=Component/ComponentPresentations&$filter=KeyName%20eq%20%27ReleaseDate%27&&%20Component/SchemaId%20=%20468%20&$orderby=DateValue%20desc%20&$top=5