Exemple #1
0
        /// <summary>
        /// Generates System.CodeDom.CodeExpression from the given expression.
        /// </summary>
        /// <param name="expression">Expression from which System.CodeDom.CodeExpression is generated.</param>
        /// <returns>Generated System.CodeDom.CodeExpression.</returns>
        public virtual CodeExpression Visit(QueryAsExpression expression)
        {
            CodeExpression    argument = this.GenerateCode(expression.Source);
            CodeTypeReference typeRef  = this.GetTypeReference(expression.TypeToOperateAgainst);

            return(argument.TypeAs(typeRef));
        }
Exemple #2
0
        /// <summary>
        /// Visits a QueryExpression tree whose root node is the QueryAsExpression.
        /// </summary>
        /// <param name="expression">The root node of the expression tree being visited.</param>
        /// <returns>Uri query string representing the expression.</returns>
        public override string Visit(QueryAsExpression expression)
        {
            var queryEntityType = expression.TypeToOperateAgainst as QueryEntityType;

            ExceptionUtilities.CheckObjectNotNull(queryEntityType, "Expected a QueryEntityType any other type is not supported");
            return(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.ComputeUriInternal(expression.Source), queryEntityType.EntityType.FullName));
        }
Exemple #3
0
        /// <summary>
        /// Evaluates the specified expression.
        /// </summary>
        /// <param name="expression">The expression to evaluate.</param>
        /// <returns>Value of the expression.</returns>
        public QueryValue Visit(QueryAsExpression expression)
        {
            QueryValue source     = this.Evaluate(expression.Source);
            QueryType  resultType = expression.TypeToOperateAgainst;

            return(source.TreatAs(resultType));
        }
        /// <summary>
        /// Replaces the given expression.
        /// </summary>
        /// <param name="expression">Expression to replace.</param>
        /// <returns>Replaced expression.</returns>
        public virtual QueryExpression Visit(QueryAsExpression expression)
        {
            var source = this.ReplaceExpression(expression.Source);

            if (this.HasChanged(expression.Source, source))
            {
                return(CommonQueryBuilder.As(source, expression.TypeToOperateAgainst));
            }

            return(expression);
        }
            /// <summary>
            /// Visits a QueryExpression tree whose root node is the QueryAsExpression.
            /// </summary>
            /// <param name="expression">The root node of the expression tree being visited.</param>
            /// <returns>
            /// Uri query string representing the expression.
            /// </returns>
            public override string Visit(QueryAsExpression expression)
            {
                var source   = this.Convert(expression.Source);
                var typeName = this.GetEdmTypeName(expression.TypeToOperateAgainst);

                if (string.IsNullOrEmpty(source))
                {
                    return(string.Format(CultureInfo.InvariantCulture, "{0}", typeName));
                }
                else
                {
                    return(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", source, typeName));
                }
            }
Exemple #6
0
        /// <summary>
        /// Returns the expand string that represents the expression.
        /// </summary>
        /// <param name="lambdaExpression">The lambda expression to convert to an expand string.</param>
        /// <returns>String representation of the lambda expression.</returns>
        private static string ToExpandString(this QueryExpression lambdaExpression)
        {
            ExceptionUtilities.CheckArgumentNotNull(lambdaExpression, "lambdaExpression");

            QueryPropertyExpression queryPropertyExpression = lambdaExpression as QueryPropertyExpression;

            ExceptionUtilities.CheckArgumentNotNull(queryPropertyExpression, "queryExpression as QueryPropertyExpression");

            QueryAsExpression queryAsExpression = queryPropertyExpression.Instance as QueryAsExpression;

            if (queryAsExpression != null)
            {
                QueryEntityType queryEntityType = queryAsExpression.TypeToOperateAgainst as QueryEntityType;
                ExceptionUtilities.CheckObjectNotNull(queryEntityType, "The type to operate against for the query As expression is not a QueryEntityType");

                return(queryEntityType.EntityType.FullName + "/" + queryPropertyExpression.Name);
            }
            else
            {
                return(queryPropertyExpression.Name);
            }
        }
 /// <summary>
 /// Visits a QueryExpression tree whose root node is the QueryAsExpression.
 /// </summary>
 /// <param name="expression">The root node of the expression tree being visited.</param>
 /// <returns>
 /// Uri query string representing the expression.
 /// </returns>
 public override string Visit(QueryAsExpression expression)
 {
     var source = this.Convert(expression.Source);
     var typeName = this.GetEdmTypeName(expression.TypeToOperateAgainst);
     if (string.IsNullOrEmpty(source))
     {
         return string.Format(CultureInfo.InvariantCulture, "{0}", typeName);
     }
     else
     {
         return string.Format(CultureInfo.InvariantCulture, "{0}/{1}", source, typeName);
     }
 }
 /// <summary>
 /// Visits a QueryExpression tree whose root node is the QueryAsExpression.
 /// </summary>
 /// <param name="expression">The root node of the expression tree being visited.</param>
 /// <returns>Uri query string representing the expression.</returns>
 public override string Visit(QueryAsExpression expression)
 {
     var queryEntityType = expression.TypeToOperateAgainst as QueryEntityType;
     ExceptionUtilities.CheckObjectNotNull(queryEntityType, "Expected a QueryEntityType any other type is not supported");
     return string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.ComputeUriInternal(expression.Source), queryEntityType.EntityType.FullName);
 }
Exemple #9
0
 /// <summary>
 /// Visits a QueryExpression tree whose root node is the QueryAsExpression.
 /// </summary>
 /// <param name="expression">The root node of the expression tree being visited.</param>
 /// <returns>Uri query string representing the expression.</returns>
 public virtual string Visit(QueryAsExpression expression)
 {
     throw new TaupoNotSupportedException("Not supported");
 }
        /// <summary>
        /// Resolves types for the specified expression.
        /// </summary>
        /// <param name="expression">The expression to resolve types for.</param>
        /// <returns>Expression with resolved types.</returns>
        public QueryExpression Visit(QueryAsExpression expression)
        {
            var source = this.ResolveTypes(expression.Source);

            return(source.As(expression.TypeToOperateAgainst));
        }