Class SqlNodeInterpreterContext
- Namespace
- LfrlAnvil.Sql.Expressions.Visitors
- Assembly
- LfrlAnvil.Sql.Core.dll
Represents a context for an SqlNodeInterpreter instance that contains the ongoing result of SQL nodes' interpretation.
public sealed class SqlNodeInterpreterContext
- Inheritance
-
SqlNodeInterpreterContext
- Inherited Members
Properties
ChildDepth
Gets the current SQL child node depth.
public int ChildDepth { get; }
Property Value
Indent
Gets the current SQL statement indentation level.
public int Indent { get; }
Property Value
Parameters
Gets the collection of registered SQL parameters.
public IReadOnlyCollection<SqlNodeInterpreterContextParameter> Parameters { get; }
Property Value
Sql
Underlying SQL builder.
public StringBuilder Sql { get; }
Property Value
Methods
AddParameter(string, TypeNullability?, int?)
Registers a new SQL parameter in this context.
public void AddParameter(string name, TypeNullability? type, int? index)
Parameters
name
stringParameter's name.
type
TypeNullability?Optional runtime type of this parameter.
index
int?Optional 0-based position of this parameter.
Remarks
When SQL parameter with the provided name
already exists, then its type and index are validated:
when new type does not equal old type, then the existing entry's type is set to null,
and when new index does not equal old index, then the existing entry's index is set to null.
AppendIndent()
public StringBuilder AppendIndent()
Returns
AppendShortIndent()
public StringBuilder AppendShortIndent()
Returns
Clear()
Resets this context to initial empty state.
public void Clear()
Create(int)
Creates a new SqlNodeInterpreterContext instance.
[Pure]
public static SqlNodeInterpreterContext Create(int capacity = 1024)
Parameters
Returns
- SqlNodeInterpreterContext
New SqlNodeInterpreterContext instance.
Create(StringBuilder)
Creates a new SqlNodeInterpreterContext instance with a prepared SQL builder.
[Pure]
public static SqlNodeInterpreterContext Create(StringBuilder builder)
Parameters
builder
StringBuilderSQL builder.
Returns
- SqlNodeInterpreterContext
New SqlNodeInterpreterContext instance.
DecreaseChildDepth()
Decreases ChildDepth by 1, if possible.
public void DecreaseChildDepth()
DecreaseIndent()
Decreases Indent by 2, if possible.
public void DecreaseIndent()
IncreaseChildDepth()
Increases ChildDepth by 1.
public void IncreaseChildDepth()
IncreaseIndent()
Increases Indent by 2.
public void IncreaseIndent()
TempChildDepthIncrease()
Increases ChildDepth by 1 and creates a new disposable SqlNodeInterpreterContext.TemporaryChildDepthIncrease instance.
public SqlNodeInterpreterContext.TemporaryChildDepthIncrease TempChildDepthIncrease()
Returns
- SqlNodeInterpreterContext.TemporaryChildDepthIncrease
New SqlNodeInterpreterContext.TemporaryChildDepthIncrease instance.
TempIndentIncrease()
Increases Indent by 2 and creates a new disposable SqlNodeInterpreterContext.TemporaryIndentIncrease instance.
public SqlNodeInterpreterContext.TemporaryIndentIncrease TempIndentIncrease()
Returns
- SqlNodeInterpreterContext.TemporaryIndentIncrease
New SqlNodeInterpreterContext.TemporaryIndentIncrease instance.
ToSnapshot()
Creates a new SqlNodeInterpreterContextSnapshot instance from the current state of this context.
[Pure]
public SqlNodeInterpreterContextSnapshot ToSnapshot()
Returns
TryGetParameter(string, out SqlNodeInterpreterContextParameter)
Attempts to retrieve an SQL parameter by its name
.
public bool TryGetParameter(string name, out SqlNodeInterpreterContextParameter result)
Parameters
name
stringParameter's name.
result
SqlNodeInterpreterContextParameterout parameter that returns found SQL parameter info.
Returns
- bool
true when SQL parameter exists, otherwise false.