/// <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); }
// 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); }