Parses the OData query expression tree and generates the proper ODataQueryOperation.
상속: System.Linq.Expressions.ExpressionVisitor
예제 #1
0
        /// <summary>
        /// Executes an OData <see cref="Expression"/>.
        /// </summary>
        /// <param name="expression">The OData query <see cref="Expression"/>.</param>
        /// <returns>The result of the OData expression execution.</returns>
        public virtual object Execute(Expression expression)
        {
            var visitor   = new ODataExpressionVisitor(expression);
            var operation = visitor.Eval();

            if (HttpContext.Current != null)
            {
                HttpContext.Current.Items.Add("ODataQueryOperation.Current", operation);
            }

            return(this.ExecuteQuery(operation));
        }
        /// <summary>
        /// Evaluates a custom <see cref="ExpressionVisitor"/> to get a resource.
        /// </summary>
        /// <param name="query">The <see cref="IQueryable"/> which contains the
        /// expression to get the resource.</param>
        /// <param name="fullTypeName">The resource full type name.</param>
        /// <returns>The expected resource.</returns>
        public object GetResource(IQueryable query, string fullTypeName)
        {
            var visitor   = new ODataExpressionVisitor(query.Expression);
            var operation = visitor.Eval() as ODataSelectOneQueryOperation;

            if (operation != null)
            {
                this.currentEntity = query.Provider.Execute(query.Expression);

                if (operation.Key.StartsWith("temp-"))
                {
                    this.currentOperation = "CreateResource";
                }
            }

            return(this.currentEntity);
        }