Пример #1
0
        /// <summary>
        ///     Executes the query and binds the results to a gridview.
        /// </summary>
        public void DataBind(SPGridView gridView, SPList list, bool initColumns)
        {
            var query = CreateSiteDataQuery(CAML.QueryScope.WebOnly);

            query.Lists = CAML.Lists(CAML.List(list.ID));
            BindToGridView(list.ParentWeb, gridView, query, initColumns);
        }
Пример #2
0
 /// <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))
         );
 }
Пример #3
0
        /// <summary>
        ///     Creates and initializes an SPSiteDataQuery object for a given scope.
        /// </summary>
        public SPSiteDataQuery CreateSiteDataQuery(CAML.QueryScope scope)
        {
            var query = new SPSiteDataQuery
            {
                Query      = QueryXml,
                ViewFields = ViewFieldsXml,
                Lists      = ListsXml
            };

            // Only use the Webs clause if the scope is different than the default.
            if (scope != CAML.QueryScope.WebOnly)
            {
                query.Webs = CAML.Webs(scope);
            }
            return(query);
        }
Пример #4
0
        /// <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));
        }