Wednesday, February 16, 2011

CAML Query

CAML stands for Collaborative Application Markup Language. This language within the context of Microsoft SharePoint Services/Foundation to define query against list data.
To simplify things, as we have SQL to perform operations of SQL Server, we have CAML to perform operations on List.
Note: With SQL, we can perform a lot more complex operations which we cannot perform in CAML.

CAML is XML like structure with some of the schema elements defined below
WHERE <Where> </Where> Just like WHERE Clause in SQL but unlike SQL where we have WHERE mostly coming in last, here our query starts with a WHERE Clause.
AND <And> </And> Just like AND Clause in SQL but as explained above, its a XML like schema so every criteria has to be inside AND Tags.
OR <Or> <Or> Similar to OR Clause in SQL but XML like schema.
EQ <Eq> <Eq> Represents a "=" (Equals To)
NEQ <Neq> <Neq> Represents a "!=" (Not Equals To)
GT <gt > <gt > Represents a ">" (Greater Than)
LT <lt > <lt > Represents a "<" (Less Than)
FieldRef <FieldRef> <FieldRef> Can be considered as a column in SQL Server but with different attributes

A standard CAML QUERY
<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>Hello World</Value></Eq></Where>
More on CAML in next post

No comments: