Пример #1
0
        /// <summary>
        /// Visits a QueryExpression tree whose root node is the LinqExpandExpression.
        /// </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(LinqToAstoriaExpandExpression expression)
        {
            string source = this.ComputeUriInternal(expression.Source);

            this.SetExpandQueryOption(expression.ExpandString);
            this.hasQueryOption = true;

            return(source);
        }
Пример #2
0
            /// <summary>
            /// Visits a LinqExpandExpression.
            /// </summary>
            /// <param name="expression">The expression.</param>
            /// <returns>The result of visiting this expression.</returns>
            public CodeExpression Visit(LinqToAstoriaExpandExpression expression)
            {
                var source = this.GenerateQueryCode(expression.Source).Expression;

                if (!expression.IsImplicit)
                {
                    Type clrType = this.GetClrType(expression.Source);
                    return(source.Cast(Code.GenericType("DataServiceQuery", clrType.FullName)).Call("Expand", Code.Primitive(expression.ExpandString)));
                }

                return(source);
            }
Пример #3
0
        /// <summary>
        /// Visits a QueryExpression tree whose root node is the LinqExpandExpression.
        /// </summary>
        /// <param name="expression">The root node of the expression tree being visited.</param>
        /// <returns>Replaced expression.</returns>
        public virtual QueryExpression Visit(LinqToAstoriaExpandExpression expression)
        {
            QueryExpression source = this.ReplaceExpression(expression.Source);

            if (HasChanged(expression.Source, source))
            {
                return(new LinqToAstoriaExpandExpression(source, expression.ExpandString, expression.ExpressionType, expression.IsImplicit));
            }
            else
            {
                return(expression);
            }
        }
Пример #4
0
            /// <summary>
            /// Visits a LinqExpandExpression.
            /// </summary>
            /// <param name="expression">The expression.</param>
            /// <returns>The result of visiting this expression.</returns>
            public Expression Visit(LinqToAstoriaExpandExpression expression)
            {
                Expression source = this.GenerateLinqExpression(expression.Source);

                if (!expression.IsImplicit)
                {
                    var queryOptionParameters = new Expression[] { Expression.Constant(expression.ExpandString) };

                    var elementType = source.Type.GetGenericArguments()[0];
                    ExceptionUtilities.Assert(elementType != null, "Element type should not be null");
                    var typedDataServiceQuery = typeof(DataServiceQuery <>).MakeGenericType(elementType);

                    var result = Expression.Call(Expression.Convert(source, typedDataServiceQuery), "Expand", new Type[] { }, queryOptionParameters);
                    return(result);
                }

                return(source);
            }
Пример #5
0
            /// <summary>
            /// Visits a LinqExpandExpression.
            /// </summary>
            /// <param name="expression">The expression.</param>
            /// <returns>Value of the expression</returns>
            public QueryValue Visit(LinqToAstoriaExpandExpression expression)
            {
                // expand is not handled here, instead it's handled in the trimming phase after
                // the whole expression has been evaluated
                var expanded = this.Evaluate(expression.Source);

                // if expanding a collection using sql strategy, we do not guarantee the order of top level set.
                var collection = expanded as QueryCollectionValue;

                if (collection != null)
                {
                    var strategy = collection.Type.ElementType.EvaluationStrategy as ILinqToAstoriaQueryEvaluationStrategy;
                    ExceptionUtilities.CheckObjectNotNull(strategy, "Cannot get astoria-specific evaluation strategy from collection value.");

                    if (!strategy.IsCollectionOrderPredictable)
                    {
                        return(QueryCollectionValue.Create(collection.Type.ElementType, collection.Elements, false));
                    }
                }

                return(expanded);
            }
Пример #6
0
        /// <summary>
        /// Visits a QueryExpression tree whose root node is the LinqExpandExpression.
        /// </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(LinqToAstoriaExpandExpression expression)
        {
            string source = this.ComputeUriInternal(expression.Source);

            this.SetExpandQueryOption(expression.ExpandString);
            this.hasQueryOption = true;

            return source;
        }
Пример #7
0
 /// <summary>
 /// Visits a QueryExpression tree whose root node is the LinqToAstoriaExpandExpression.
 /// </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(LinqToAstoriaExpandExpression expression)
 {
     throw new TaupoNotSupportedException("Not supported");
 }
Пример #8
0
        /// <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(LinqToAstoriaExpandExpression expression)
        {
            var source = this.ResolveTypes(expression.Source);

            return(new LinqToAstoriaExpandExpression(source, expression.ExpandString, source.ExpressionType, expression.IsImplicit));
        }