using Connected.Expressions.Collections; using Connected.Expressions.Formatters; using Connected.Expressions.Translation; using System.Collections.ObjectModel; using System.Linq.Expressions; namespace Connected.Expressions; public sealed class SelectExpression : AliasedExpression { public SelectExpression(Alias alias, IEnumerable columns, Expression from, Expression? where, IEnumerable? orderBy, IEnumerable? groupBy, bool isDistinct, Expression? skip, Expression? take, bool isReverse) : base(DatabaseExpressionType.Select, typeof(void), alias) { Columns = columns.ToReadOnly(); IsDistinct = isDistinct; From = from; Where = where; OrderBy = orderBy?.ToReadOnly(); GroupBy = groupBy?.ToReadOnly(); Take = take; Skip = skip; IsReverse = isReverse; } public SelectExpression(Alias alias, IEnumerable columns, Expression from, Expression? where, IEnumerable? orderBy, IEnumerable? groupBy) : this(alias, columns, from, where, orderBy, groupBy, false, null, null, false) { } public SelectExpression(Alias alias, IEnumerable columns, Expression from, Expression? where) : this(alias, columns, from, where, null, null) { } public ReadOnlyCollection Columns { get; } public Expression From { get; } public Expression? Where { get; } public ReadOnlyCollection? OrderBy { get; } public ReadOnlyCollection? GroupBy { get; } public bool IsDistinct { get; } public Expression? Skip { get; } public Expression? Take { get; } public bool IsReverse { get; } public string QueryText => SqlFormatter.Format(this); }