Table of Contents

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

QueryCommand QueryCommand

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

QueryCommand

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

object

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

ind int

Property Value

object

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

condition ReadOnlySpan<char>

Property Value

object

this[string]

The value set for the named variable or condition, or null when it is off.

public object? this[string condition] { get; }

Parameters

condition string

Property Value

object

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

string

Remove(ReadOnlySpan<char>)

Turns off the named variable or condition so its part drops from the query.

public void Remove(ReadOnlySpan<char> condition)

Parameters

condition ReadOnlySpan<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

condition string

The 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

conditionIndex int

The condition index.

UnUse(ReadOnlySpan<char>)

Turns off a condition previously turned on with Use(string).

public bool UnUse(ReadOnlySpan<char> condition)

Parameters

condition ReadOnlySpan<char>

The condition name.

Returns

bool

true if the name is a condition, false if it names a value-carrying variable instead.

UnUse(string)

Turns off a condition previously turned on with Use(string).

public bool UnUse(string condition)

Parameters

condition string

The condition name.

Returns

bool

true if the name is a condition, false if it names a value-carrying variable instead.

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

charVariable char

The variable character the query uses, such as @.

variable string

The variable name, without the leading character.

value object

The value to bind.

Returns

bool

true if the name is a value-carrying variable and was set.

Use(int)

Turns on the condition at conditionIndex.

public void Use(int conditionIndex)

Parameters

conditionIndex int

The condition index.

Use(int, object?)

public bool Use(int variableIndex, object? value)

Parameters

variableIndex int
value object

Returns

bool

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

condition ReadOnlySpan<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

variable ReadOnlySpan<char>

The variable name.

value object

The value to bind.

Returns

bool

true if the name is a value-carrying variable and was set.

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

condition string

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(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

variable string

The variable name.

value object

The value to bind.

Returns

bool

true if the name is a value-carrying variable and was set.

UseWith(object)

Copies the usable values from an object into this builder.

public void UseWith(object parameterObj)

Parameters

parameterObj object

UseWith<T>(T)

Copies the usable values from an object into this builder.

public void UseWith<T>(T parameterObj) where T : notnull

Parameters

parameterObj T

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

parameterObj T

Type Parameters

T