I have written this code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
ClientContext c = new ClientContext("http://sp2013");
Web w = c.Web;
c.Load(w);
c.ExecuteQuery();
List l = w.Lists.GetByTitle("Discussions");
c.Load(l);
c.ExecuteQuery();
Console.WriteLine(l.Title);
CamlQuery query = new CamlQuery();
query.ViewXml = "<View Scope='Recursive'><Query><Where></And><Eq><FieldRef Name='ParentFolderId'/><Value Type='Integer'>1</Value></Eq><Eq><FieldRef Name='PostType'/><Value Type='Text'>Answer</Value></Eq></And></Where></Query></View>";
ListItemCollection itemCollection = l.GetItems(query);
c.Load(itemCollection);
c.ExecuteQuery();
Console.WriteLine(itemCollection.Count);
foreach (var x in itemCollection) {
Console.WriteLine(x["Body"]);
Console.WriteLine(x["ParentFolderId"]);
Console.WriteLine(x["PostType"]);
}
}
}
}the code runs fine but returns everything rather than only the items with PostType of "Answer". So the AND part of the query is not working. No Errors!
val it: unit=()