Class SqlQuery
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
rootStatementSqlStatementThe root statement of the SQL query.
syntaxOptionsSqlSyntaxOptionsSyntax options describing identifier handling for the query.
Exceptions
- ArgumentNullException
Thrown when
rootStatementis 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
RootStatement
Gets the root statement of the query.
public SqlStatement RootStatement { get; }
Property Value
SyntaxOptions
Gets the syntax options associated with the query.
public SqlSyntaxOptions SyntaxOptions { get; }
Property Value
Methods
ToSql(SqlFormattingOptions?)
Reconstructs the SQL text from the analysed structure.
public string ToSql(SqlFormattingOptions? options = null)
Parameters
optionsSqlFormattingOptionsFormatting options controlling the SQL output.
Returns
- string
A SQL string equivalent to the parsed statement.