Example #1
0
        private static void GetAndDeleteItem()
        {
            CSOMOperation op = SiteUrl
                               .Create(logger)
                               .SetOnlineCredentials(ClientSecrets.Username, ClientSecrets.Password)
                               .Execute();

            op.LoadList("Documents")
            .Execute();

            ListItem item = op.GetItem(1);

            ListItemCollection items = op.GetItems(x => x.Id, x => x.DisplayName);
        }
Example #2
0
        /// <summary>
        /// Get items from the last loaded list using CAML query
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="queryString">CAML query string used for selection
        /// When <paramref name="rowLimit"/> is used the <paramref name="queryString"/> is wrapped into View tag with Scope="RecursiveAll".
        /// Also when there is not View tag in the <paramref name="queryString"/> it is wrapped into simple View tag with Scope="RecursiveAll"
        /// </param>
        /// <param name="rowLimit"></param>
        /// <returns>Loaded list items in standard CSOM <see cref="ListItemCollection"/></returns>
        /// <remarks>
        /// If you need bigger control over the CAML query use alternative <seealso cref="GetItems(KeenMate.FluentlySharePoint.CSOMOperation,CamlQuery)"/> method with CamlQuery parameter
        /// </remarks>
        public static ListItemCollection GetItems(this CSOMOperation operation, string queryString, int?rowLimit = null, params Expression <Func <ListItem, object> >[] retrievals)
        {
            string caml = queryString;

            if (rowLimit != null)
            {
                caml = string.Format(CamlQueries.WrappedWithRowLimit, queryString, rowLimit);
            }
            else
            {
                if (!caml.ToLower().Contains("<view>"))
                {
                    caml = $"<View Scope=\"RecursiveAll\">{queryString}</View>";
                }
            }
            var ca = new CamlQuery {
                ViewXml = caml
            };

            return(operation.GetItems(ca, retrievals));
        }