Table of Contents

Struct QueryFactory

Namespace
Rinku.Querying
Assembly
Rinku.dll

Reads a SQL template into its text, conditional parts, handlers, and named value slots. Use it when subclassing QueryCommand to change how a template is read.

public struct QueryFactory
Inherited Members
Extension Methods

Constructors

QueryFactory(string, char, uint)

Reads a template and fills in the pieces. A suffix letter that specialHandlerPresenceMap claims is left for a special handler to bind later, one in BaseHandlerMapper binds its built-in handler, and a letter that is neither is rejected.

public QueryFactory(string query, char variableChar = '\0', uint specialHandlerPresenceMap = 0)

Parameters

query string

The SQL template to read.

variableChar char

The character that marks a variable, @ when left unset.

specialHandlerPresenceMap uint

The suffix letters a special handler layer claims for itself.

QueryFactory(string, IEnumerable<string>)

Fills in the pieces for a command whose variables are named rather than read out of the text. The text is taken as written and every name becomes a required variable, which is what a call that carries its parameters somewhere other than its SQL needs, a stored procedure most of all.

public QueryFactory(string commandText, IEnumerable<string> variableNames)

Parameters

commandText string

The text to send, a procedure's name or any SQL, used exactly as given.

variableNames IEnumerable<string>

The parameters to bind, in order. A name already marked as a variable is taken as written, and one that is not is marked with DefaultVariableChar, so Id and @Id name the same parameter. Nothing here is parsed, so there is no template to say which character marks a variable and the app-wide one answers.

Fields

BaseHandlerMapper

The built-in handler letters and how each expands, keyed by suffix. S quotes a string, R injects raw text, N writes a number. App-wide and mutable, add a letter here to register your own handler for every command.

public static readonly LetterMap<HandlerGetter<IQuerySegmentHandler>> BaseHandlerMapper

Field Value

LetterMap<HandlerGetter<IQuerySegmentHandler>>

BaseHandlerPresenceMap

Which base-handler letters are free to use, the ones a special handler has not claimed.

public uint BaseHandlerPresenceMap

Field Value

uint

Conditions

The optional parts and the keys that switch them on or off.

public Condition[] Conditions

Field Value

Condition[]

DefaultVariableChar

The character that marks a variable when a command does not name its own. @ to start.

public static char DefaultVariableChar

Field Value

char

Mapper

The map from each key name to its slot, the shared numbering the rest of the pieces address.

public Mapper Mapper

Field Value

Mapper

NbBaseHandlers

How many variables are expanded by a built-in base handler.

public int NbBaseHandlers

Field Value

int

NbNonVarComment

How many conditional markers are neither a variable nor a projected column.

public int NbNonVarComment

Field Value

int

NbNormalVar

How many plain value-carrying variables the template has, required and optional together.

public int NbNormalVar

Field Value

int

NbRequired

How many keys are required, so a run must always supply them.

public int NbRequired

Field Value

int

NbSpecialHandlers

How many variables are expanded by a special handler.

public int NbSpecialHandlers

Field Value

int

Query

The template text with the markers stripped, the SQL a run with everything present would send.

public string Query

Field Value

string

Segments

The template broken into the runs of text and handler spots that make up the SQL.

public QuerySegment[] Segments

Field Value

QuerySegment[]

Methods

IsBaseHandler(char)

Whether a suffix letter is a base handler that is free to use here.

public readonly bool IsBaseHandler(char c)

Parameters

c char

Returns

bool