A class that normalizes C# and VB expression trees.
Inheritance: ExpressionVisitor
        /// <summary>
        /// Translate a MongoDB LINQ query.
        /// </summary>
        /// <param name="provider">The MongoDB query provider.</param>
        /// <param name="expression">The LINQ query expression.</param>
        /// <returns>A TranslatedQuery.</returns>
        public static TranslatedQuery Translate(MongoQueryProvider provider, Expression expression)
        {
            expression = PartialEvaluator.Evaluate(expression, provider);
            expression = ExpressionNormalizer.Normalize(expression);
            // assume for now it's a SelectQuery
            var documentType = GetDocumentType(expression);
            var selectQuery  = new SelectQuery(provider.Collection, documentType);

            selectQuery.Translate(expression);
            return(selectQuery);
        }
Ejemplo n.º 2
0
 // public methods
 /// <summary>
 /// Normalizes C# and VB expression trees.
 /// </summary>
 /// <param name="node">The expression to normalize.</param>
 /// <returns>The normalized expression.</returns>
 public static Expression Normalize(Expression node)
 {
     var normalizer = new ExpressionNormalizer(node);
     return normalizer.Visit(node);
 }
        // public methods
        /// <summary>
        /// Normalizes C# and VB expression trees.
        /// </summary>
        /// <param name="node">The expression to normalize.</param>
        /// <returns>The normalized expression.</returns>
        public static Expression Normalize(Expression node)
        {
            var normalizer = new ExpressionNormalizer(node);

            return(normalizer.Visit(node));
        }