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

I am using ClientContext Class and CAML query to retrieve items from External List in sharepoint 2010.I have built the query with Logical AND Condition in CAML Query like this

 string sDataFilter =<Query><Where><And><Eq><FieldRef Name="Year" /><Value Type="Text">1960</Value></Eq><Contains><FieldRef Name="ChartName" /><Value Type="Text">Chart1</Value></Contains></And></Where></Query>

When I exceute the following code

List oList = clientContext.Web.Lists.GetById(new Guid(list));
               CamlQuery camlQuery = new CamlQuery();
               string queryContext = "<View><Query>" + sDataFilter + "</Query>" + viewFieldsContext + "</View>";
               camlQuery.ViewXml = queryContext;
               ListItemCollection collListItem = oList.GetItems(camlQuery);

I am getting the empty ListItemCollection.I have cross verified with the U2U CAML Query Builder the data is empty only. So in External List the caml query is working fine for sorting and simple filter query like Where,EqualTo condition I can't use Logical conditions in the query ? If yes how could I achieve this using caml query Could anyone help me to resolve this issue ?

share|improve this question
Is it correct that you're "sDataFilter" starts and ends with the <Query>-tag and you place it within another <Query>-tag in your "queryContext"? – Ruben Herman Mar 23 '12 at 6:53

Try to remove <Query> </Query> tag inside sDataFilter.


share|improve this answer

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.