Thursday, October 21, 2010

How to write Nested Query in CAML

It's strange that CAML query can only compare a pair of expressions either by <And> or <Or>. So if you have a query like you want to filter <And> condition between two <Or> condition, then you need to use nested <And> or <Or>, in which each operator only takes two expressions. This will make things more complicate especially for a number of conditions mixed with <And> and <Or>.

Example :

            <FieldRef Name="Expires" />
            <Value Type="DateTime"><Today/>Value>
            <FieldRef Name="SubCategory" />
            <Value Type="Choice">PreLoginValue>
            <FieldRef Name="SubCategory" />
            <Value Type="Choice">BothValue>


Special Thanks to Mr.Abhay Wad.

No comments:

Post a Comment