Table of Contents

Class SqlQuery

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

Represents the root of an analysed SQL statement.

public sealed class SqlQuery
Inheritance
SqlQuery
Inherited Members
Extension Methods

Constructors

SqlQuery(SqlStatement, SqlSyntaxOptions?)

Initializes a new instance of the SqlQuery class.

public SqlQuery(SqlStatement rootStatement, SqlSyntaxOptions? syntaxOptions = null)

Parameters

rootStatement SqlStatement

The root statement of the SQL query.

syntaxOptions SqlSyntaxOptions

Syntax options describing identifier handling for the query.

Exceptions

ArgumentNullException

Thrown when rootStatement is null.

Properties

AllStatements

Gets all statements contained in the query, including the root and nested statements such as CTEs or subqueries. The collection is rebuilt on each access so that modifications applied to the query tree are reflected immediately.

public IReadOnlyList<SqlStatement> AllStatements { get; }

Property Value

IReadOnlyList<SqlStatement>

RootStatement

Gets the root statement of the query.

public SqlStatement RootStatement { get; }

Property Value

SqlStatement

SyntaxOptions

Gets the syntax options associated with the query.

public SqlSyntaxOptions SyntaxOptions { get; }

Property Value

SqlSyntaxOptions

Methods

ToSql(SqlFormattingOptions?)

Reconstructs the SQL text from the analysed structure.

public string ToSql(SqlFormattingOptions? options = null)

Parameters

options SqlFormattingOptions

Formatting options controlling the SQL output.

Returns

string

A SQL string equivalent to the parsed statement.