public static bool FindExists(Expression expression, Predicate<Expression> isMatch) { var finder = new ExpressionsFinder(isMatch, true); finder.Visit(expression); return finder.results.Count > 0; }
public static Expression First(Expression expression, Predicate<Expression> isMatch) { var finder = new ExpressionsFinder(isMatch, true); finder.Visit(expression); return finder.results.FirstOrDefault(); }
public static List<Expression> FindAll(Expression expression, Predicate<Expression> isMatch) { var finder = new ExpressionsFinder(isMatch, false); finder.Visit(expression); return finder.results; }
public static List <Expression> FindAll(Expression expression, Predicate <Expression> isMatch) { var finder = new ExpressionsFinder(isMatch, false); finder.Visit(expression); return(finder.results); }
public static Expression First(Expression expression, Predicate <Expression> isMatch) { var finder = new ExpressionsFinder(isMatch, true); finder.Visit(expression); return(finder.results.FirstOrDefault()); }
public static bool FindExists(Expression expression, Predicate <Expression> isMatch) { var finder = new ExpressionsFinder(isMatch, true); finder.Visit(expression); return(finder.results.Count > 0); }
protected override Expression VisitSelect(SqlSelectExpression select) { var saveIsOuterMostSelect = this.isOuterMostSelect; try { this.isOuterMostSelect = false; select = (SqlSelectExpression)base.VisitSelect(select); var hasOrderBy = select.OrderBy != null && select.OrderBy.Count > 0; if (hasOrderBy) { this.PrependOrderings(select.OrderBy.Select(c => (SqlOrderByExpression)c)); } var canHaveOrderBy = saveIsOuterMostSelect && !ExpressionsFinder.FindExists(select, c => c.NodeType == (ExpressionType)SqlExpressionType.Aggregate || c.NodeType == (ExpressionType)SqlExpressionType.AggregateSubquery); var canPassOnOrderings = !saveIsOuterMostSelect; var columns = select.Columns; IEnumerable <Expression> orderings = (canHaveOrderBy) ? this.gatheredOrderings : null; if (this.gatheredOrderings != null) { if (canPassOnOrderings) { var producedAliases = AliasesProduced.Gather(select.From); var project = this.RebindOrderings(this.gatheredOrderings, select.Alias, producedAliases, select.Columns); this.gatheredOrderings = project.Orderings; columns = project.Columns; } else { this.gatheredOrderings = null; } } if (canHaveOrderBy && (orderings != select.OrderBy || columns != select.Columns)) { select = new SqlSelectExpression(select.Type, select.Alias, columns, select.From, select.Where, orderings, select.GroupBy, select.Distinct, select.Skip, select.Take, select.ForUpdate); } return(select); } finally { this.isOuterMostSelect = saveIsOuterMostSelect; } }