Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
               clientContext.Load(collListItem);
               clientContext.ExecuteQuery();

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
2  
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

1 Answer 1

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

Regards

share|improve this answer

Your Answer

 
discard

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.