コード例 #1
0
        /// <summary>
        /// Gets the count treshold to minimize the number of elements retrieved from TFS
        /// </summary>
        private int GetTopRequestValue(ODataQueryOperation operation, FilterNode parameters)
        {
            int topRequestValue = int.MaxValue;

            if (parameters == null || !parameters.Any(p => p.Key.Equals("Owner") || p.Key.Equals("CreationDate") || p.Key.Equals("Comment") || p.Key.Equals("ArtifactUri")))
            {
                if (operation.IsCountRequest)
                {
                    if (!string.IsNullOrEmpty(operation.ContinuationToken))
                    {
                        var parts = operation.ContinuationToken.Split(':').Select(int.Parse);
                        topRequestValue = parts.First() + parts.Last() + 1;
                    }
                }
                else
                {
                    if (operation.TopCount > 0)
                    {
                        topRequestValue = operation.TopCount + operation.SkipCount + 1;
                    }
                }
            }

            return topRequestValue;
        }