/// <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(LinqNewInstanceExpression expression)
        {
            var constructorArguments = expression.ConstructorArguments.Select(this.ResolveTypes).ToList();
            var members = expression.Members.Select(this.ResolveTypes).ToList();

            return(LinqBuilder.NewInstance(constructorArguments, expression.MemberNames, members, expression.ExpressionType));
        }
Exemple #2
0
        /// <summary>
        /// Replaces the given expression.
        /// </summary>
        /// <param name="expression">The root node of the expression tree being visited.</param>
        /// <returns>Replaced expression.</returns>
        public virtual QueryExpression Visit(LinqNewInstanceExpression expression)
        {
            QueryExpression[] members = expression.Members.Select(this.ReplaceExpression).ToArray();
            QueryExpression[] constructorArguments = expression.ConstructorArguments.Select(this.ReplaceExpression).ToArray();
            if (HasChanged(expression.Members, members) || HasChanged(expression.ConstructorArguments, constructorArguments))
            {
                return(LinqBuilder.NewInstance(constructorArguments, expression.MemberNames, members, expression.ExpressionType));
            }

            return(expression);
        }