private static QueryContext GetQueryContext(ActionExecutingContext actionContext)
        {
            var hasQuery = actionContext.HttpContext.Items.ContainsKey(Constants.QueryContextPropertyName);
            QueryContext query;

            if (hasQuery)
            {
                query = actionContext.HttpContext.Items[Constants.QueryContextPropertyName]
                    as QueryContext;
            }
            else
            {
                query = new QueryContext();
                actionContext.HttpContext.Items.Add(Constants.QueryContextPropertyName, query);
            }

            return query;
        }
        private static QueryContext GetQueryContext(HttpActionContext actionContext)
        {
            var hasQuery = actionContext.Request.Properties.ContainsKey(Constants.PropertyNames.QueryContext);
            QueryContext query;

            if (hasQuery)
            {
                query = actionContext.Request.Properties[Constants.PropertyNames.QueryContext]
                    as QueryContext;
            }
            else
            {
                query = new QueryContext();
                actionContext.Request.Properties.Add(Constants.PropertyNames.QueryContext, query);
            }

            return query;
        }
        public static ResourceResult PreprocessResult(object result, ApiResource resource, QueryContext queryContext)
        {
            if (queryContext?.Filtering != null)
            {
                result = Query.ApplyFiltering(result, queryContext.Filtering, resource);
            }

            if (queryContext?.Sorting != null)
            {
                result = Query.ApplySorting(result, queryContext.Sorting, resource);
            }

            if (queryContext?.Pagination != null)
            {
                result = Query.ApplyPagination(result, queryContext.Pagination, resource);
            }

            return new ResourceResult
            {
                Resource = resource,
                Result = result,
                QueryContext = queryContext
            };
        }