I am trying to retrieve a list of items including lookup fields via listdata.svc. My lookup points to a list of companies which has the following fields: Title, Address, Phone.

By default, listdata doesn't return the lookup data, only a link to it. If I use the $expand parameter, then listdata returns all the fields of the lookup.

How can I make listdata return the lookup Title only, not the other fields like Address and Phone?


This page has some good examples on using listdata.svc and specific examples on drilling down into specific items to be selected.

Using the REST Interface

Examples from page

Using code:

var query = (DataServiceQuery<InventoryLocationsItem>)context.
       .Where(p => p.Part.SKU.StartsWith(SearchSku)).OrderBy(p => p.Part.SKU);

Manually constructing the URL:

  • thx, I'll try this. The [list]/[column] notation seems to be what I'm looking for. – Christophe Dec 29 '11 at 1:02
  • Worked great! Do you happen to know how to get rid of the _metadata? – Christophe Dec 29 '11 at 1:29
  • Unfortunately, no, I do not know how to get rid of the _metadata. – Alban Dec 29 '11 at 15:27
  • 1
    It shows 'An error occurred while processing this request' if the lookup value is null. Please Help – Shreyas Nov 5 '15 at 6:57

Assuming that the Title is the "foreign key" don't you already have that value in the primary list? Alternatively, don't you get the values if you add the other columns to the Lookup column to pull them across with the key?

  • No you don't (contrary to what Web services will do for example). You don't get the lookup id either. Let's say that REST services are very "performance concious" ;-) – Christophe Dec 29 '11 at 0:49

Your Answer

