I am developing a console application to extract data from a SharePoint 2013 server using the [.NET client object model](https://msdn.microsoft.com/en-us/library/office/Dn423226.aspx#bk_QueryNETcsom) of the [SharePoint Server 2013 Client Components SDK](http://www.microsoft.com/en-us/download/details.aspx?id=35585):

```
using (var clientContext = new ClientContext(SharePointUrl))
{
    var list = clientContext.Web.Lists.GetByTitle(listName);
    var camlQuery = CamlQuery.CreateAllItemsQuery();
    var listItems = list.GetItems(camlQuery);
    clientContext.Load(listItems, GetFields(fields));
    clientContext.ExecuteQuery();
    return listItems.ToList();
}

```

This is the GetFields() method I call to construct the list of fields I request:

```
private Expression<Func<ListItemCollection, object>>[] GetFields(IEnumerable<string> fields)
{
    return fields
        .Select(field => (Expression<Func<ListItemCollection, object>>)(items => items.Include(item => item[field])))
        .ToArray();
}

```

---

There is one big list -- `"Demands"` -- that is giving me troubles for some User-type fields: **whenever I include these as a field that needs to be retrieved** via the `GetFields()` method (see above), **I get [the infamous "Value does not fall within the expected range." error](https://sharepoint.stackexchange.com/q/105397/45188)**. For instance, `"DTBusinessResponsible"` can be retrieved, yet `"DTSupplyLeadResponsible"` cannot.

I have been informed that `"Demands"` contains two `ContentTypes`: `"Demand"` and `"I-Demand"`. The fields that are giving me issues are exclusive to `"I-Demand"`.

---

I cannot figure out how I can retrieve these problematic fields. I've tried retrieving the `ContentType`s for `"Demand"` and `"I-Demand"` and adding them to `list`:

```
var demandContentType = clientContext.Web.ContentTypes.GetById(contentTypeByName["Demand"]);
var iDemandContentType = clientContext.Web.ContentTypes.GetById(contentTypeByName["I-Demand"]);

list.ContentTypesEnabled = true;
list.ContentTypes.AddExistingContentType(demandContentType);
list.ContentTypes.AddExistingContentType(iDemandContentType);

```

But this is no use, I get an error telling me both `ContentType`s are already present.

---

(Note that [I have already asked this over at the SharePoint SE](https://sharepoint.stackexchange.com/q/156640/45188), but I didn't get any useful responses there.)

---

**EDIT: Let's simplify the question.** 

I need to retrieve a number of fields from a SharePoint List called `"Demands"`. To that end, I add the fields I require as [`Expression<Func<T, object>>[]`](https://msdn.microsoft.com/en-us/library/office/jj171831.aspx).

However, some of the fields I need to retrieve are exclusive to `"I-Demand"`, which is one of the `ContentTypes` of the `"Demands"` list. Whenever I add those fields, the query crashes and produces [the infamous "Value does not fall within the expected range." error](https://sharepoint.stackexchange.com/q/105397/45188). I have no trouble retrieving dozens of other fields which are all part of the `"Demand"` content type.

How can I retrieve those fields that are exclusive to the `"I-Demand"` content type?

---

**EDIT: Here's what doesn't work...** 

```
var fields = new List<string>
{
    "DTBusinessRequestor",
    "DTBusinessResponsible",
    "DTBusinessSponsor",
    "DTDemandAccountable",
    "DTIICTBusinessAnalyst",
    "DTSupplyAccountable",
    "DTSupplyLeadResponsible",
    "Title",
    "Author",
    "Created",
    "Editor",
    "Modified",
    "ID"
};

var viewXml = new StringBuilder();

viewXml.AppendLine("<ViewFields>");
foreach (var field in fields)
{
    viewXml.AppendFormat("<FieldRef Name=\"{0}\" />", field).AppendLine();
}
viewXml.AppendLine("</ViewFields>");

var camlQuery = new CamlQuery { ViewXml = string.Format("<View>{0}</View>", viewXml) };

List<ListItem> results;

using (var clientContext = GetClientContext())
{
    var list = clientContext.Web.Lists.GetByTitle("Demands");
    var listItems = list.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    results = listItems.ToList();
}

var validNames = new HashSet<string>();

foreach (var listItem in results)
{
    foreach (var field in fields)
    {
        object value;
        if (!listItem.FieldValues.TryGetValue(field, out value))
            continue;

        if (value != null)
        {
            validNames.Add(field);
        }
    }
}

```

When I execute the above code:

* `results` contains 10 (ten) items while there are 160 entries in SharePoint;
* `validNames` contains six fields: "Title", "Author", "Created", "Editor", "Modified", "ID".

Which is a slightly better result than the one I had, since "Author" and "Editor" were problematic. The rest of the fields return null, but that could be because the ten results do not have values. However, I cannot compare to the values in SharePoint since the ten titles that are returned are ***not*** ones that are found in the Demands table...

---

I try to filter by ContentType by adding this line after `viewXml.AppendLine("</ViewFields>");`:

```
viewXml.AppendLine("<Query><Where><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>I-Demand</Value></Eq></Where></Query>");

```

Result: `results` contains no entries.

---

I remove the filter by ContentType and change this:

```
var camlQuery = new CamlQuery { ViewXml = string.Format("<View>{0}</View>", viewXml) };

```

to this:

```
var camlQuery = CamlQuery.CreateAllItemsQuery();
camlQuery.ViewXml = string.Format("<View>{0}</View>", viewXml);

```

Same result as originally: ten items, same fields.

I then remove this line:

```
camlQuery.ViewXml = string.Format("<View>{0}</View>", viewXml);

```

Result: 160 items, values for "DTBusinessRequestor", "DTBusinessResponsible", "DTBusinessSponsor" and "DTIICTBusinessAnalyst" ***BUT*** no results for "Author" and "Editor" -- so I'm back where I started.

---

I have not found a single solution where it returns me values for all 160 entries in the Demands list combined with values for "Author" and "Editor" and also "DTDemandAccountable", "DTSupplyAccountable" and "DTSupplyLeadResponsible" (where applicable). 

Whenever I add `<Query><Where><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>I-Demand</Value></Eq></Where></Query>` I get zero results.