This project has moved and is read-only. For the latest updates, please go here.

Dynamically adding an 'OR' statement

Oct 23, 2011 at 4:31 PM

I am successfully using the following

var expressions = new List<Expression<Func<SPListItem, bool>>>();
expressions.Add(x => (int)x["ID"] == 1);
expressions.Add(y => (string)y["Title"] == "Hello world");

string caml = Camlex.Query().WhereAll(expressions).ToString();


however the two .Add statements issue a 'AND' operator in CAML, I would like to .Add an OR statement.  How do I do this?




Oct 23, 2011 at 6:57 PM
Edited Oct 23, 2011 at 6:59 PM

hi suz7777,

as I understand you need to create expressions which looks like this: (a & b) || c. In order to do this you can use ExpressionsHelper class and its CombineOr() method. In this discussion Vladimir wrote how to use it: In your case at first you need to join a and b conditions using CombineAnd() method (you will have "(a & b)" after this), and then join condition c using CombineOr() so as result you will have "(a & b) || c".