You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Connected.Expressions.Expressions;
|
|
|
|
|
using Connected.Expressions.Visitors;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
|
|
|
|
namespace Connected.Expressions.Translation;
|
|
|
|
|
|
|
|
|
|
public sealed class AggregateChecker : DatabaseVisitor
|
|
|
|
|
{
|
|
|
|
|
private AggregateChecker()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool HasAggregate { get; set; }
|
|
|
|
|
|
|
|
|
|
public static bool HasAggregates(SelectExpression expression)
|
|
|
|
|
{
|
|
|
|
|
var checker = new AggregateChecker();
|
|
|
|
|
|
|
|
|
|
checker.Visit(expression);
|
|
|
|
|
|
|
|
|
|
return checker.HasAggregate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Expression VisitAggregate(AggregateExpression aggregate)
|
|
|
|
|
{
|
|
|
|
|
HasAggregate = true;
|
|
|
|
|
|
|
|
|
|
return aggregate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Expression VisitSelect(SelectExpression select)
|
|
|
|
|
{
|
|
|
|
|
Visit(select.Where);
|
|
|
|
|
VisitOrderBy(select.OrderBy);
|
|
|
|
|
VisitColumnDeclarations(select.Columns);
|
|
|
|
|
|
|
|
|
|
return select;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Expression VisitSubquery(SubqueryExpression subquery) => subquery;
|
|
|
|
|
}
|