Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

[CAML] AND condition does not work!

$
0
0

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=()


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>