0

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 ?

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

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

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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