Struct QueryBuilderCommand<TCommand>
- Namespace
- Rinku
- Assembly
- Rinku.dll
Holds the values for a run and keeps a live IDbCommand in step with them. Each time you set a variable the matching command parameter is added, updated, or dropped on the spot, so the command is always ready to run. Bind one command and a loop reuses it across a batch without rebuilding it each pass.
public readonly struct QueryBuilderCommand<TCommand> : IQueryBuilder where TCommand : IDbCommand
Type Parameters
TCommand
- Implements
- Inherited Members
- Extension Methods
Remarks
This is the live-command counterpart to QueryBuilder, which keeps its values in memory and builds a command only when it runs.
Constructors
QueryBuilderCommand(QueryCommand, TCommand)
Holds the values for a run and keeps a live IDbCommand in step with them. Each time you set a variable the matching command parameter is added, updated, or dropped on the spot, so the command is always ready to run. Bind one command and a loop reuses it across a batch without rebuilding it each pass.
public QueryBuilderCommand(QueryCommand QueryCommand, TCommand Command)
Parameters
QueryCommandQueryCommandCommandTCommand
Remarks
This is the live-command counterpart to QueryBuilder, which keeps its values in memory and builds a command only when it runs.
Fields
Command
The live command kept in step with the values.
public readonly TCommand Command
Field Value
- TCommand
QueryCommand
The command these values run against.
public readonly QueryCommand QueryCommand
Field Value
Variables
The values for this run, one slot per key. Setting a slot also updates the matching parameter on Command.
public readonly object?[] Variables
Field Value
- object[]
Properties
this[int]
The value set for the variable or condition at ind, or null
when it is off.
public object? this[int ind] { get; }
Parameters
indint
Property Value
this[ReadOnlySpan<char>]
The value set for the named variable or condition, or null when it is off.
public object? this[ReadOnlySpan<char> condition] { get; }
Parameters
conditionReadOnlySpan<char>
Property Value
this[string]
The value set for the named variable or condition, or null when it is off.
public object? this[string condition] { get; }
Parameters
conditionstring
Property Value
Methods
GetQueryText()
The SQL text for the current state, with the off pieces dropped. Reads the state alone and touches no command, so you can inspect what a run would send without executing it.
public string GetQueryText()
Returns
Remove(int)
public void Remove(int ind)
Parameters
indint
Remove(ReadOnlySpan<char>)
Turns off the named variable or condition so its part drops from the query.
public void Remove(ReadOnlySpan<char> condition)
Parameters
conditionReadOnlySpan<char>The variable or condition name.
Remove(string)
Turns off the named variable or condition so its part drops from the query.
public void Remove(string condition)
Parameters
conditionstringThe variable or condition name.
Reset()
Turns everything off, back to the state of a fresh builder.
public void Reset()
SetDefaults()
Explicitly materializes missing default-capable parameters on the live command.
public void SetDefaults()
UnUse(int)
Turns off the condition at conditionIndex.
public void UnUse(int conditionIndex)
Parameters
conditionIndexintThe condition index.
UnUse(ReadOnlySpan<char>)
Turns off a condition previously turned on with Use(string).
public bool UnUse(ReadOnlySpan<char> condition)
Parameters
conditionReadOnlySpan<char>The condition name.
Returns
UnUse(string)
Turns off a condition previously turned on with Use(string).
public bool UnUse(string condition)
Parameters
conditionstringThe condition name.
Returns
Use(char, string, object?)
Sets a variable to value and turns it on, spelling the variable character apart
from the name so the name can come from nameof.
public bool Use(char charVariable, string variable, object? value)
Parameters
charVariablecharThe variable character the query uses, such as
@.variablestringThe variable name, without the leading character.
valueobjectThe value to bind.
Returns
Use(int)
Turns on the condition at conditionIndex.
public void Use(int conditionIndex)
Parameters
conditionIndexintThe condition index.
Use(int, object?)
public bool Use(int variableIndex, object? value)
Parameters
Returns
Use(ReadOnlySpan<char>)
Turns on a condition, a piece that carries no value (a conditional marker or a projected column).
public bool Use(ReadOnlySpan<char> condition)
Parameters
conditionReadOnlySpan<char>The condition name.
Returns
- bool
true if the name is a condition and was turned on, false if it names a value-carrying variable instead.
Use(ReadOnlySpan<char>, object?)
Sets a variable to value and turns it on. A null value turns it off.
public bool Use(ReadOnlySpan<char> variable, object? value)
Parameters
variableReadOnlySpan<char>The variable name.
valueobjectThe value to bind.
Returns
Use(string)
Turns on a condition, a piece that carries no value (a conditional marker or a projected column).
public bool Use(string condition)
Parameters
conditionstringThe condition name.
Returns
- bool
true if the name is a condition and was turned on, false if it names a value-carrying variable instead.
Use(string, object?)
Sets a variable to value and turns it on. A null value turns it off.
public bool Use(string variable, object? value)
Parameters
Returns
UseWith(object)
Replaces the current values from an object and updates the live command. Special handlers receive the supplied values before they are written.
public void UseWith(object parameterObj)
Parameters
parameterObjobject
UseWith<T>(T)
Replaces the current values from an object and updates the live command. Special handlers receive the supplied values before they are written.
public void UseWith<T>(T parameterObj) where T : notnull
Parameters
parameterObjT
Type Parameters
T
UseWith<T>(ref T)
Replaces the current values from an object and updates the live command. Special handlers receive the supplied values before they are written.
public void UseWith<T>(ref T parameterObj) where T : notnull
Parameters
parameterObjT
Type Parameters
T