internal override Expression VisitInputReferenceExpression(InputReferenceExpression ire)
        {
            Debug.Assert(ire != null, "ire != null");
            if (this.parent == null || this.parent.NodeType != ExpressionType.MemberAccess)
            {
                string expressionText = (this.parent != null) ? this.parent.ToString() : ire.ToString();
                throw new NotSupportedException(Strings.ALinq_CantTranslateExpression(expressionText));
            }

            return(ire);
        }
        internal static string ExpressionToString(DataServiceContext context, Expression e)
        {
            ExpressionWriter ew         = new ExpressionWriter(context);
            string           serialized = ew.Translate(e);

            if (ew.cantTranslateExpression)
            {
                throw new NotSupportedException(Strings.ALinq_CantTranslateExpression(e.ToString()));
            }

            return(serialized);
        }
Пример #3
0
        /// <summary>
        /// Serializes an expression to a string
        /// </summary>
        /// <param name='context'>Data context used to generate type names for types.</param>
        /// <param name="e">Expression to serialize</param>
        /// <param name='inPath'>Whether or not the expression being written is part of the path of the URI.</param>
        /// <param name="uriVersion">the request data service version for the uri</param>
        /// <returns>serialized expression</returns>
        internal static string ExpressionToString(DataServiceContext context, Expression e, bool inPath, ref Version uriVersion)
        {
            ExpressionWriter ew         = new ExpressionWriter(context, inPath);
            string           serialized = ew.Translate(e);

            WebUtil.RaiseVersion(ref uriVersion, ew.uriVersion);
            if (ew.cantTranslateExpression)
            {
                throw new NotSupportedException(Strings.ALinq_CantTranslateExpression(e.ToString()));
            }

            return(serialized);
        }
        /// <summary>
        /// Input resource set references are intentionally omitted from the URL string.
        /// </summary>
        /// <param name="ire">The input reference</param>
        /// <returns>The same input reference expression</returns>
        internal override Expression VisitInputReferenceExpression(InputReferenceExpression ire)
        {
            // This method intentionally does not write anything to the URI.
            // This is how 'Where(<input>.Id == 5)' becomes '$filter=Id eq 5'.
            Debug.Assert(ire != null, "ire != null");
            if (this.parent == null || this.parent.NodeType != ExpressionType.MemberAccess)
            {
                // Ideally we refer to the parent expression as the un-translatable one,
                // because we cannot reference 'this' as a standalone expression; however
                // if the parent is null for any reasonn, we fall back to the expression itself.
                string expressionText = (this.parent != null) ? this.parent.ToString() : ire.ToString();
                throw new NotSupportedException(Strings.ALinq_CantTranslateExpression(expressionText));
            }

            return(ire);
        }
Пример #5
0
        /// <summary>
        /// Input resource set references are intentionally omitted from the URL string for the top level
        /// refences to input parameter (i.e. outside of any/all methods).
        /// For parameter references to input (range variable for Where) inside any/all methods we write "$it".
        /// </summary>
        /// <param name="ire">The input reference</param>
        /// <returns>The same input reference expression</returns>
        internal override Expression VisitInputReferenceExpression(InputReferenceExpression ire)
        {
            // This method intentionally does not write anything to the URI for implicit references to the input parameter ($it).
            // This is how 'Where(<input>.Id == 5)' becomes '$filter=Id eq 5'.
            Debug.Assert(ire != null, "ire != null");
            if (this.parent == null || (!this.InSubScope && this.parent.NodeType != ExpressionType.MemberAccess && this.parent.NodeType != ExpressionType.TypeAs))
            {
                // Ideally we refer to the parent expression as the un-translatable one,
                // because we cannot reference 'this' as a standalone expression; however
                // if the parent is null for any reasonn, we fall back to the expression itself.
                string expressionText = (this.parent != null) ? this.parent.ToString() : ire.ToString();
                throw new NotSupportedException(Strings.ALinq_CantTranslateExpression(expressionText));
            }

            // Write "$it" for input parameter reference inside any/all methods
            if (this.InSubScope)
            {
                this.builder.Append(XmlConstants.ImplicitFilterParameter);
            }

            return(ire);
        }