Ejemplo n.º 1
0
        /// <summary>
        /// Executes a count-only query in a subfolder on the server.
        /// </summary>
        /// <param name="path">Content path.</param>
        /// <param name="query">Content query text. If it is empty, the count of children will be returned.</param>
        /// <param name="server">Target server.</param>
        /// <returns>Count of result content.</returns>
        public static async Task <int> GetCountAsync(string path, string query, ServerContext server = null)
        {
            var request = new ODataRequest(server)
            {
                Path = path,
                IsCollectionRequest = true,
                ContentQuery        = query,
                CountOnly           = true
            };

            return(await RESTCaller.GetCountAsync(request, server).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes a count-only query in a subfolder on the server.
        /// </summary>
        /// <param name="path">Content path.</param>
        /// <param name="query">Content query text. If it is empty, the count of children will be returned.</param>
        /// <param name="server">Target server.</param>
        /// <returns>Count of result content.</returns>
        public static async Task <int> GetCountAsync(string path, string query, ServerContext server = null)
        {
            var request = new ODataRequest
            {
                SiteUrl             = ServerContext.GetUrl(server),
                Path                = path,
                IsCollectionRequest = true,
                CountOnly           = true
            };

            if (!string.IsNullOrEmpty(query))
            {
                request.Parameters.Add("query", query);
            }

            return(await RESTCaller.GetCountAsync(request, server));
        }