I am using the IN Operator in SharePoint 2010 CAML query to get my desired set of results, however, the filter criteria doesn't seem to work and returns all records instead of the filtered set.
Here's how my SharePoint List is laid out; the text in bracket shows the actual column name:
Department (Title) Approver (Approver)
------------------ --------------------
Department 1 Bob
Department 2 Mike
Department 1 John
Department 3 Peter
Here's how my code looks like (EDITED, THIS WORKS!!):
string camlQuery = @"<View><Query><Where>
<In>
<FieldRef Name='Title' />
<Values>
<Value Type='Text'>Department 1</Value>
</Values>
</In>
</Where></Query></View>";
string siteUrl = "http://mysharepointsite/sitename";
ClientContext _clientContext = new ClientContext(siteUrl);
List _oList = _clientContext.Web.Lists.GetByTitle(listName);
CamlQuery _camlQuery = new CamlQuery();
_camlQuery.ViewXml = camlQuery;
ListItemCollection listItemCollection = _oList.GetItems(_camlQuery);
_clientContext.Load(listItemCollection);
_clientContext.ExecuteQuery();
return listItemCollection;
It should ideally return Bob and John, but it returns all 4 approvers.
Is there anything I'm doing wrong? Thanks!