/// <summary>
        /// See base class documentation.
        /// </summary>
        /// <param name="actionContext">The action context.</param>
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            EnsureAttributeNotSpecified<DisableDefaultIncludedAttribute>(actionContext.ActionDescriptor, actionContext);
            EnsureAttributeNotSpecified<AllowsQueryAttribute>(actionContext.ActionDescriptor, actionContext);

            var queryParams = actionContext.Request.GetQueryNameValuePairs().ToList();
            var queryContext = QueryContextUtils.GetQueryContext(actionContext);

            queryContext.IsHandledQuery = true;
            queryContext.Sort = new SortContext(queryParams);
            queryContext.Filter = new FilterContext(queryParams);

            if (queryContext.Include == null)
            {
                queryContext.Include = new IncludeContext(queryParams);
            }
            else
            {
                queryContext.Include.SetIncludes(queryParams);
            }

            // we validate if action has QueryContext parameter
            // and if it has it, then we pass it
            var parameters = actionContext.ActionDescriptor.GetParameters();
            foreach (var parameter in parameters)
            {
                if (parameter.ParameterType == typeof(QueryContext))
                {
                    actionContext.ActionArguments[parameter.ParameterName] = queryContext;
                }
            }

            base.OnActionExecuting(actionContext);
        }
Esempio n. 2
0
        /// <summary>
        /// See base class documentation.
        /// </summary>
        /// <param name="actionContext">The action context.</param>
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var queryContext = QueryContextUtils.GetQueryContext(actionContext);

            if (queryContext.Include == null)
            {
                queryContext.Include = new IncludeContext();
            }

            queryContext.Include.DisableDefaultIncluded = true;

            base.OnActionExecuting(actionContext);
        }
Esempio n. 3
0
        /// <summary>
        /// See base class documentation.
        /// </summary>
        /// <param name="actionContext">The action context.</param>
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var queryParams  = actionContext.Request.GetQueryNameValuePairs().ToList();
            var queryContext = QueryContextUtils.GetQueryContext(actionContext);

            queryContext.Sorting   = new SortingContext(queryParams);
            queryContext.Filtering = new FilteringContext(queryParams);

            if (queryContext.Including == null)
            {
                queryContext.Including = new IncludingContext(queryParams);
            }
            else
            {
                queryContext.Including.SetIncludes(queryParams);
            }

            base.OnActionExecuting(actionContext);
        }