Class CAML
Use this class to build your CAML xml and avoid XML issues.
Inheritance
Namespace: PnP.Framework.Utilities
Assembly: PnP.Framework.dll
Syntax
public static class CAML : object
Examples
CAML.ViewQuery( CAML.Where( CAML.And( CAML.Eq(CAML.FieldValue("Project", "Integer", "{0}")), CAML.Geq(CAML.FieldValue("StartDate","DateTime", CAML.Today())) ) ), CAML.OrderBy( new OrderByField("StartDate", false), new OrderByField("Title") ), rowLimit: 5 );
Fields
Me
Declaration
public static readonly string Me
Field Value
System.
|
Month
Declaration
public static readonly string Month
Field Value
System.
|
Now
Declaration
public static readonly string Now
Field Value
System.
|
Methods
And(String, String[])
Creates <And> node
Declaration
public static string And(string clause1, params string[] conditionClauses)
Parameters
System. Clause |
System. Clause Condition |
Returns
System. Returns Condition string to be used in CAML queries |
BeginsWith(String)
Creates <BeginsWith> node for Comparison
Declaration
public static string BeginsWith(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Contains(String)
Creates <Contains> node for Comparison
Declaration
public static string Contains(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
DateRangesOverlap(String)
Creates <DateRangesOverlap> node for Comparison
Declaration
public static string DateRangesOverlap(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Eq(String)
Creates <Eq> node for Comparison
Declaration
public static string Eq(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
FieldRef(String)
Creates a <FieldRef> node for ViewFields clause
Declaration
public static string FieldRef(string fieldName)
Parameters
System. Name of the field |
Returns
System. Returns FieldRef string to be used in CAML queries |
FieldValue(Guid, String, String, String)
Creates both a <FieldRef> and <Value> nodes combination for Where clauses.
Declaration
public static string FieldValue(Guid fieldId, string fieldValueType, string value, string additionalFieldRefParams = "")
Parameters
Guid
fieldId
Id of the field |
System. Value type of the field |
System. Value of the field |
System. Additional FieldRef Parameters |
Returns
System. Returns FieldValue string to be used in CAML queries |
FieldValue(String, String, String, String)
Creates both a <FieldRef> and <Value> nodes combination for Where clauses.
Declaration
public static string FieldValue(string fieldName, string fieldValueType, string value, string additionalFieldRefParams = "")
Parameters
System. Name of the field |
System. Value type of the field |
System. Value of the field |
System. Additional FieldRef Parameters |
Returns
System. Returns FieldValue string to be used in CAML queries |
Geq(String)
Creates <Geq> node for Comparison
Declaration
public static string Geq(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Gt(String)
Creates <Gt> node for Comparison
Declaration
public static string Gt(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
In(String)
Creates <In> node for Comparison
Declaration
public static string In(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
In(String, String[])
Creates <In> node for Comparison
Declaration
public static string In(string fieldRef, params string[] values)
Parameters
System. Field Reference |
System. Value strings to be included inside the <In>-clause |
Returns
System. Returns Comparison string to be used in CAML queries |
Includes(String)
Creates <Includes> node for Comparison
Declaration
public static string Includes(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
IsNotNull(String)
Creates <IsNotNull> node for Comparison
Declaration
public static string IsNotNull(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
IsNull(String)
Creates <IsNull> node for Comparison
Declaration
public static string IsNull(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Leq(String)
Creates <Leq> node for Comparison
Declaration
public static string Leq(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Lt(String)
Creates <Lt> node for Comparison
Declaration
public static string Lt(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Neq(String)
Creates <Neq> node for Comparison
Declaration
public static string Neq(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
NotIncludes(String)
Creates <NotIncludes> node for Comparison
Declaration
public static string NotIncludes(string fieldValue)
Parameters
System. Value of the field |
Returns
System. Returns Comparison string to be used in CAML queries |
Or(String, String[])
Creates <Or> node
Declaration
public static string Or(string clause1, params string[] conditionClauses)
Parameters
System. Clause |
System. Clause Condition |
Returns
System. Returns Condition string to be used in CAML queries |
OrderBy(OrderByField[])
Creates <OrederBy> node for sorting by field
Declaration
public static string OrderBy(params OrderByField[] fieldRefs)
Parameters
Order Field References |
Returns
System. Returns string to be used in CAML queries |
Today(Nullable<Int32>)
Creates the <Today /> node.
Declaration
public static string Today(int? offset = null)
Parameters
System. Time offset from today (+5 days or -5 days, for example). |
Returns
System. Returns <Today /> node based on offset value |
Value(String, String)
Creates a <Value> node for In comparison clauses.
Declaration
public static string Value(string value, string fieldValueType)
Parameters
System. Value of the field |
System. Value type of the field |
Returns
System. Value string to be used for In comparisions in CAML queries |
ViewFields(String[])
Creates <ViewFields> node for ViewFields clause
Declaration
public static string ViewFields(params string[] fieldRefs)
Parameters
System. Field References |
Returns
System. Returns string to be used in CAML queries |
ViewQuery(String, String, Int32)
Root <View> and <Query> nodes.
Declaration
public static string ViewQuery(string whereClause = "", string orderByClause = "", int rowLimit = 100)
Parameters
System. <Where> node. |
System. <OrderBy> node. |
System. <RowLimit> node. |
Returns
System. String to be used in CAML queries |
ViewQuery(ViewScope, String, String, String, Int32)
Root <View> and <Query> nodes.
Declaration
public static string ViewQuery(ViewScope scope, string whereClause = "", string orderByClause = "", string viewFields = "", int rowLimit = 100)
Parameters
View View scope |
System. <Where> node. |
System. <OrderBy> node. |
System. <ViewFields> node. |
System. <RowLimit> node. |
Returns
System. String to be used in CAML queries |
Where(String)
Creates <Where> node for Where clause
Declaration
public static string Where(string conditionClause)
Parameters
System. The Clause condition |
Returns
System. Returns string to be used in CAML queries |