Thursday, August 3, 2017

SharePoint: CAML Query not working based on WHERE clause

When we write the CAML query in SharePoint development and if we put WHERE clause in query it still returns all records.


For example look at the below query, it works fine in U2U builder but returns all records if we use the same in code.


SPQuery query = new SPQuery();
query.Query = "<Query><Where></Where></Query>"


Here is the Fix:

Remove the "<Query>" Tag and rewrite it

SPQuery query = new SPQuery();
query.Query = "<Where></Where>"

No comments:

Post a Comment