SqlParser
Namespace: PPJ.Runtime.Sql
Assembly: PPJ.Runtime.50 (5.0.0.0)
Converts SAL bind markers and INTO clauses into provider SQL and parameter descriptions.
- C#
- VB.NET
public class SqlParser
Public Class SqlParser
Use a new parser for each independent statement; the parser retains the bind and INTO lists it builds.
Example:
using PPJ.Runtime.Sql;
var parser = new SqlParser();
string sql = parser.ParseSql("SELECT Name INTO :customerName FROM Customers WHERE Id = :customerId");
int inputCount = parser.BindList.Count;
Constructors
SqlParser()
Initializes a parser with named parameters enabled and the @ parameter prefix.
Properties
BindList
ArrayList: Gets the parsed bind parameter descriptions.
IntoList
ArrayList: Gets the parsed INTO target descriptions.
IsCommand
Boolean: Gets or sets whether the input is a command whose INTO clause must not be extracted.
NamedParameters
Boolean: Gets or sets whether provider markers use generated parameter names.
OptimizeParameters
Boolean: Gets or sets whether repeated bind expressions reuse an existing parameter description.
ParametersPrefix
String: Gets or sets the prefix used to generate provider parameter markers.
PositionalParameters
Boolean: Gets or sets whether generated parameter markers use parameter positions.
Methods
FixCommand(command)
Normalizes procedure arguments by adding missing colon bind markers.
| Parameter | Type | Description |
|---|---|---|
| command | String | The procedure invocation text to normalize. |
Returns: String. The trimmed command with normalized argument markers.
FixList(list)
Normalizes a comma-separated bind list by adding missing colon markers.
| Parameter | Type | Description |
|---|---|---|
| list | String | The comma-separated variable expressions to parse or normalize. |
Returns: String. The normalized list, or the original value when null or empty.
ParseInto(list)
Parses an INTO target list into the parser's target collection.
| Parameter | Type | Description |
|---|---|---|
| list | String | The comma-separated variable expressions to parse or normalize. |
ParseSql(sql)
Extracts INTO targets and replaces bind expressions with provider parameter markers.
| Parameter | Type | Description |
|---|---|---|
| sql | String | The SQL statement containing SAL bind markers and an optional INTO clause. |
Returns: String. The SQL text to send to the provider.