/// <summary> /// This method gives an example of how to construct CamlQuery objects /// using the constructor that accepts the entire query string. /// </summary> /// <remarks> /// Note that you simply append the GroupBy and OrderBy clauses to the /// query string. /// </remarks> public static void Example() { var q = new CamlQuery( CAML.Where( CAML.Contains( CAML.FieldRef("Author"), CAML.Value("Holliday") )) + CAML.GroupBy( CAML.FieldRef("Title")) + CAML.OrderBy( CAML.FieldRef("Title", CAML.SortType.Ascending), CAML.FieldRef("Author", CAML.SortType.Descending)) ); }
/// <summary> /// Retrieves all documents of type "Job Sheet" from a given list. /// </summary> /// <param name="list">the SPList containing the documents</param> public static SPListItemCollection GetJobSheets(SPList list) { // Create a new query object. var query = new SPQuery { // Assign the query string by using the raw CAML.NET string conversion operators. Query = CAML.Where( CAML.Eq( CAML.FieldRef("Document Type"), CAML.Value("Job Sheet") ) ) }; // Assign the query string by using the raw CAML.NET string conversion operators. // Execute the query to obtain the matching list items. return(list.GetItems(query)); }