Struct QueryBuilder
- Namespace
- Rinku
- Assembly
- Rinku.dll
Holds the values for one run of a QueryCommand. Use it when you want to set values and conditions one at a time before running the query.
public readonly struct QueryBuilder : IQueryBuilder
- Implements
- Inherited Members
- Extension Methods
Remarks
Use QueryBuilderCommand<TCommand> when each change should also update one live IDbCommand for repeated execution.
Constructors
QueryBuilder(QueryCommand)
Holds the values for one run of a QueryCommand. Use it when you want to set values and conditions one at a time before running the query.
public QueryBuilder(QueryCommand QueryCommand)
Parameters
QueryCommandQueryCommand
Remarks
Use QueryBuilderCommand<TCommand> when each change should also update one live IDbCommand for repeated execution.
Fields
QueryCommand
The command these values run against.
public readonly QueryCommand QueryCommand
Field Value
Used
The value stored for a condition that is on but carries no data. Pass it where a value is expected to mean "present" for a toggle-only piece.
public static readonly object Used
Field Value
Variables
The values for this run, one slot per key in the command. A slot is null when its piece is off, a bound value when a variable is set, and Used when a toggle-only condition is on.
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(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()
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)
Copies the usable values from an object into this builder.
public void UseWith(object parameterObj)
Parameters
parameterObjobject
UseWith<T>(T)
Copies the usable values from an object into this builder.
public void UseWith<T>(T parameterObj) where T : notnull
Parameters
parameterObjT
Type Parameters
T
UseWith<T>(ref T)
Copies the usable values from an object into this builder.
public void UseWith<T>(ref T parameterObj) where T : notnull
Parameters
parameterObjT
Type Parameters
T