Struct QueryFactory
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
querystringThe SQL template to read.
variableCharcharThe character that marks a variable,
@when left unset.specialHandlerPresenceMapuintThe 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
commandTextstringThe text to send, a procedure's name or any SQL, used exactly as given.
variableNamesIEnumerable<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
Idand@Idname 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
BaseHandlerPresenceMap
Which base-handler letters are free to use, the ones a special handler has not claimed.
public uint BaseHandlerPresenceMap
Field Value
Conditions
The optional parts and the keys that switch them on or off.
public Condition[] Conditions
Field Value
DefaultVariableChar
The character that marks a variable when a command does not name its own. @ to start.
public static char DefaultVariableChar
Field Value
Mapper
The map from each key name to its slot, the shared numbering the rest of the pieces address.
public Mapper Mapper
Field Value
NbBaseHandlers
How many variables are expanded by a built-in base handler.
public int NbBaseHandlers
Field Value
NbNonVarComment
How many conditional markers are neither a variable nor a projected column.
public int NbNonVarComment
Field Value
NbNormalVar
How many plain value-carrying variables the template has, required and optional together.
public int NbNormalVar
Field Value
NbRequired
How many keys are required, so a run must always supply them.
public int NbRequired
Field Value
NbSpecialHandlers
How many variables are expanded by a special handler.
public int NbSpecialHandlers
Field Value
Query
The template text with the markers stripped, the SQL a run with everything present would send.
public string Query
Field Value
Segments
The template broken into the runs of text and handler spots that make up the SQL.
public QuerySegment[] Segments
Field Value
Methods
IsBaseHandler(char)
Whether a suffix letter is a base handler that is free to use here.
public readonly bool IsBaseHandler(char c)
Parameters
cchar