SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I like in SharePoint Client Object model is that you can make batch queries. What I cannot find is if it's possible to get related items (linked by lookup field) in the same query?

An example would be: - A list Partners with fields: Title, Address, ZIP, City and Country (lookup to Countries) - A list Countries with fields: Title, Abbreviation, Continent (Lookup to Continents)

If I'd want to load also a Continent for each partner (cannot be done through related fields in Lookup column), I'd need to first load the list of partners and then afterwards an additional query to load countries for each of the partner. Is it possible to do this in one query?

Currently this goes something like this (unoptimized, just for demo purpose):

ClientContext ctx = new ClientContext("http://mydemospsite");
List lst = ctx.Web.Lists.GetByTitle("Partners");
List lstCountries = ctx.Web.Lists.GetByTitle("Countries");
CamlQuery qry = new CamlQuery() { ViewXml = "" };

ListItemCollection itms = lst.GetItems(qry);


ctx.ExecuteQueryAsync((o, e) => 
   foreach(ListItem itm in itms) 
       ListItem itmCountry = lstCountries.GetItemById(((FieldLookupValue)itm["Country"]).LookupId);
       //Do whatever, link the item,...
   ctx.ExecuteQueryAsync(null, null);
(o, e) => 
    Dispatcher.BeginInvoke(() => 

The sample above is poor and serves only as an example of the problem. Is it possible to load also (only) related countries without running the ExecuteQueryAsync twice?

share|improve this question
up vote 1 down vote accepted

Your CAML query can join Partners and Countries so you can get the Continent as a projected field.

share|improve this answer
Seems like the only way to do it :) And then translate projected fields over to my own objects. – Gomiunik Jan 28 '12 at 21:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.