Table of Contents

Class SqlSelectStatement

Namespace
Utils.Data.Sql
Assembly
Utils.Data.dll

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

select SqlSegment

The SELECT segment.

from SqlSegment

The FROM segment.

where SqlSegment

The WHERE segment.

groupBy SqlSegment

The GROUP BY segment.

having SqlSegment

The HAVING segment.

orderBy SqlSegment

The ORDER BY segment.

limit SqlSegment

The LIMIT segment.

offset SqlSegment

The OFFSET segment.

tail SqlSegment

Additional segments such as UNION clauses.

withClause WithClause

Optional CTE definitions.

isDistinct bool

Indicates whether the SELECT statement is distinct.

Properties

From

Gets the FROM segment describing the data sources.

public SqlSegment? From { get; }

Property Value

SqlSegment

FromPart

Gets the FROM clause represented as a typed part.

public FromPart? FromPart { get; }

Property Value

FromPart

GroupBy

Gets the GROUP BY segment.

public SqlSegment? GroupBy { get; }

Property Value

SqlSegment

GroupByPart

Gets the GROUP BY clause represented as a typed part.

public GroupByPart? GroupByPart { get; }

Property Value

GroupByPart

Having

Gets the HAVING segment.

public SqlSegment? Having { get; }

Property Value

SqlSegment

HavingPart

Gets the HAVING clause represented as a typed part.

public HavingPart? HavingPart { get; }

Property Value

HavingPart

IsDistinct

Gets a value indicating whether the SELECT statement includes DISTINCT.

public bool IsDistinct { get; }

Property Value

bool

Limit

Gets the LIMIT segment.

public SqlSegment? Limit { get; }

Property Value

SqlSegment

LimitPart

Gets the LIMIT clause represented as a typed part.

public LimitPart? LimitPart { get; }

Property Value

LimitPart

Offset

Gets the OFFSET segment.

public SqlSegment? Offset { get; }

Property Value

SqlSegment

OffsetPart

Gets the OFFSET clause represented as a typed part.

public OffsetPart? OffsetPart { get; }

Property Value

OffsetPart

OrderBy

Gets the ORDER BY segment.

public SqlSegment? OrderBy { get; }

Property Value

SqlSegment

OrderByPart

Gets the ORDER BY clause represented as a typed part.

public OrderByPart? OrderByPart { get; }

Property Value

OrderByPart

Select

Gets the SELECT segment describing the selected expressions.

public SqlSegment Select { get; }

Property Value

SqlSegment

SelectPart

Gets the SELECT clause represented as a typed part.

public SelectPart SelectPart { get; }

Property Value

SelectPart

Tail

Gets any trailing segments such as UNION clauses.

public SqlSegment? Tail { get; }

Property Value

SqlSegment

TailPart

Gets the trailing set operator clause represented as a typed part.

public TailPart? TailPart { get; }

Property Value

TailPart

Where

Gets the WHERE segment containing the filtering conditions.

public SqlSegment? Where { get; }

Property Value

SqlSegment

WherePart

Gets the WHERE clause represented as a typed part.

public WherePart? WherePart { get; }

Property Value

WherePart

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.