コード例 #1
0
        /// <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(SequoiaQueryProvider 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);
        }
コード例 #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));
        }
コード例 #3
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);
 }