Class SqlSelectStatement
Represents a parsed SELECT statement.
public sealed class SqlSelectStatement : SqlStatement
- Inheritance
-
SqlSelectStatement
- Inherited Members
- Extension Methods
Constructors
SqlSelectStatement(SqlSegment, SqlSegment?, SqlSegment?, SqlSegment?, SqlSegment?, SqlSegment?, SqlSegment?, SqlSegment?, SqlSegment?, WithClause?, bool)
Initializes a new instance of the SqlSelectStatement class.
public SqlSelectStatement(SqlSegment select, SqlSegment? from, SqlSegment? where, SqlSegment? groupBy, SqlSegment? having, SqlSegment? orderBy, SqlSegment? limit, SqlSegment? offset, SqlSegment? tail, WithClause? withClause, bool isDistinct)
Parameters
selectSqlSegmentThe SELECT segment.
fromSqlSegmentThe FROM segment.
whereSqlSegmentThe WHERE segment.
groupBySqlSegmentThe GROUP BY segment.
havingSqlSegmentThe HAVING segment.
orderBySqlSegmentThe ORDER BY segment.
limitSqlSegmentThe LIMIT segment.
offsetSqlSegmentThe OFFSET segment.
tailSqlSegmentAdditional segments such as UNION clauses.
withClauseWithClauseOptional CTE definitions.
isDistinctboolIndicates whether the SELECT statement is distinct.
Properties
From
Gets the FROM segment describing the data sources.
public SqlSegment? From { get; }
Property Value
FromPart
Gets the FROM clause represented as a typed part.
public FromPart? FromPart { get; }
Property Value
GroupBy
Gets the GROUP BY segment.
public SqlSegment? GroupBy { get; }
Property Value
GroupByPart
Gets the GROUP BY clause represented as a typed part.
public GroupByPart? GroupByPart { get; }
Property Value
Having
Gets the HAVING segment.
public SqlSegment? Having { get; }
Property Value
HavingPart
Gets the HAVING clause represented as a typed part.
public HavingPart? HavingPart { get; }
Property Value
IsDistinct
Gets a value indicating whether the SELECT statement includes DISTINCT.
public bool IsDistinct { get; }
Property Value
Limit
Gets the LIMIT segment.
public SqlSegment? Limit { get; }
Property Value
LimitPart
Gets the LIMIT clause represented as a typed part.
public LimitPart? LimitPart { get; }
Property Value
Offset
Gets the OFFSET segment.
public SqlSegment? Offset { get; }
Property Value
OffsetPart
Gets the OFFSET clause represented as a typed part.
public OffsetPart? OffsetPart { get; }
Property Value
OrderBy
Gets the ORDER BY segment.
public SqlSegment? OrderBy { get; }
Property Value
OrderByPart
Gets the ORDER BY clause represented as a typed part.
public OrderByPart? OrderByPart { get; }
Property Value
Select
Gets the SELECT segment describing the selected expressions.
public SqlSegment Select { get; }
Property Value
SelectPart
Gets the SELECT clause represented as a typed part.
public SelectPart SelectPart { get; }
Property Value
Tail
Gets any trailing segments such as UNION clauses.
public SqlSegment? Tail { get; }
Property Value
TailPart
Gets the trailing set operator clause represented as a typed part.
public TailPart? TailPart { get; }
Property Value
Where
Gets the WHERE segment containing the filtering conditions.
public SqlSegment? Where { get; }
Property Value
WherePart
Gets the WHERE clause represented as a typed part.
public WherePart? WherePart { get; }
Property Value
Methods
BuildSql()
Builds the canonical inline SQL representation of the statement.
protected override string BuildSql()
Returns
- string
The inline SQL string representing the statement.
EnsureFromSegment()
Ensures the FROM segment exists and returns it.
public SqlSegment EnsureFromSegment()
Returns
- SqlSegment
The existing or newly created FROM segment.
EnsureGroupBySegment()
Ensures the GROUP BY segment exists and returns it.
public SqlSegment EnsureGroupBySegment()
Returns
- SqlSegment
The existing or newly created GROUP BY segment.
EnsureHavingSegment()
Ensures the HAVING segment exists and returns it.
public SqlSegment EnsureHavingSegment()
Returns
- SqlSegment
The existing or newly created HAVING segment.
EnsureLimitSegment()
Ensures the LIMIT segment exists and returns it.
public SqlSegment EnsureLimitSegment()
Returns
- SqlSegment
The existing or newly created LIMIT segment.
EnsureOffsetSegment()
Ensures the OFFSET segment exists and returns it.
public SqlSegment EnsureOffsetSegment()
Returns
- SqlSegment
The existing or newly created OFFSET segment.
EnsureOrderBySegment()
Ensures the ORDER BY segment exists and returns it.
public SqlSegment EnsureOrderBySegment()
Returns
- SqlSegment
The existing or newly created ORDER BY segment.
EnsureTailSegment()
Ensures the trailing set operator segment exists and returns it.
public SqlSegment EnsureTailSegment()
Returns
- SqlSegment
The existing or newly created trailing segment.
EnsureWhereSegment()
Ensures the WHERE segment exists and returns it.
public SqlSegment EnsureWhereSegment()
Returns
- SqlSegment
The existing or newly created WHERE segment.