C# Класс Azavea.Open.DAO.SQL.SqlUtilities

This class holds static utility methods having to do with constructing SQL statements (typically statements that would then be used with the SqlConnectionUtilities class). This class is stateless and thus is threadsafe.
Показать файл Открыть проект

Открытые методы

Метод Описание
FindParameterPlaceholders ( IDbCommand command ) : int[]

All SQL strings generated by FastDAO use ? as the parameter placeholder. For a database that needs another format, an AbstractSqlConnectionDescriptor subclass needs to swap the ?s out with something else. This helper

FindParameterPlaceholders ( string sql ) : int[]

All SQL strings generated by FastDAO use ? as the parameter placeholder. For a database that needs another format, an AbstractSqlConnectionDescriptor subclass needs to swap the ?s out with something else. This helper

MakeDeleteStatement ( string table, object>.IDictionary whereCols, IList sqlParams ) : string

Generates a delete statement to delete rows where "key" = whereCols["key"] for everything in whereCols.

MakeInsertStatement ( string table, object>.IDictionary columns, IList sqlParams ) : string

Generates an insert statement to insert the values from the dictionary into the specified table. Uses parameters for the values, the values will be taken from the dictionary and inserted into sqlParams in the same order the column names are inserted in the sql string.

MakeInsertStatement ( string table, object>.IDictionary columns, IList sqlParams, string>.IDictionary valueStrings ) : string

Generates an insert statement to insert the values from the dictionary into the specified table. Uses parameters for the values, the values will be taken from the dictionary and inserted into sqlParams in the same order the column names are inserted in the sql string.

MakeUpdateStatement ( string table, object>.IDictionary whereCols, object>.IDictionary columns, IList sqlParams ) : string

Generates an update statement to update rows where "key" = whereCols["key"] for everything in whereCols.

MakeWhereClause ( object>.IDictionary whereCols, IList sqlParams ) : string

Helper method to generate a where clause, where keys = values. You can simply concatenate this on the end of an SQL statement ("SELECT something " + MakeWhereClause(...)).

SqlParamsToString ( string sql, IEnumerable sqlParams ) : string

Converts the sql statement and parameters into a nicely formatted string for output in error messages or log statements.

Описание методов

FindParameterPlaceholders() публичный статический Метод

All SQL strings generated by FastDAO use ? as the parameter placeholder. For a database that needs another format, an AbstractSqlConnectionDescriptor subclass needs to swap the ?s out with something else. This helper
Thrown if the command is not CommandType.Text.
public static FindParameterPlaceholders ( IDbCommand command ) : int[]
command IDbCommand The command whose text should be searched for ? characters.
Результат int[]

FindParameterPlaceholders() публичный статический Метод

All SQL strings generated by FastDAO use ? as the parameter placeholder. For a database that needs another format, an AbstractSqlConnectionDescriptor subclass needs to swap the ?s out with something else. This helper
public static FindParameterPlaceholders ( string sql ) : int[]
sql string The SQL string with embedded ? placeholders.
Результат int[]

MakeDeleteStatement() публичный статический Метод

Generates a delete statement to delete rows where "key" = whereCols["key"] for everything in whereCols.
public static MakeDeleteStatement ( string table, object>.IDictionary whereCols, IList sqlParams ) : string
table string Name of the table to be inserted into.
whereCols object>.IDictionary Dictionary of object column values keyed by string column names. /// These columns are used in the "where" clause of the statement. If /// this collection is null or empty, all rows will be updated.
sqlParams IList List to insert sql param values (in order) into.
Результат string

MakeInsertStatement() публичный статический Метод

Generates an insert statement to insert the values from the dictionary into the specified table. Uses parameters for the values, the values will be taken from the dictionary and inserted into sqlParams in the same order the column names are inserted in the sql string.
public static MakeInsertStatement ( string table, object>.IDictionary columns, IList sqlParams ) : string
table string Name of the table to be inserted into.
columns object>.IDictionary Dictionary of object column values keyed by string column names.
sqlParams IList List to insert sql param values (in order) into.
Результат string

MakeInsertStatement() публичный статический Метод

Generates an insert statement to insert the values from the dictionary into the specified table. Uses parameters for the values, the values will be taken from the dictionary and inserted into sqlParams in the same order the column names are inserted in the sql string.
public static MakeInsertStatement ( string table, object>.IDictionary columns, IList sqlParams, string>.IDictionary valueStrings ) : string
table string Name of the table to be inserted into.
columns object>.IDictionary Dictionary of object column values keyed by string column names.
sqlParams IList List to insert sql param values (in order) into.
valueStrings string>.IDictionary Optional dictionary of parameter placeholders to use instead of ?.
Результат string

MakeUpdateStatement() публичный статический Метод

Generates an update statement to update rows where "key" = whereCols["key"] for everything in whereCols.
public static MakeUpdateStatement ( string table, object>.IDictionary whereCols, object>.IDictionary columns, IList sqlParams ) : string
table string Name of the table to be inserted into.
whereCols object>.IDictionary Dictionary of object column values keyed by string column names. /// These columns are used in the "where" clause of the statement. If /// this collection is null or empty, all rows will be updated.
columns object>.IDictionary Dictionary of object column values keyed by string column names. These /// columns are the values that will be set on the row(s). This collection /// may not be null or empty.
sqlParams IList List to insert sql param values (in order) into.
Результат string

MakeWhereClause() публичный статический Метод

Helper method to generate a where clause, where keys = values. You can simply concatenate this on the end of an SQL statement ("SELECT something " + MakeWhereClause(...)).
public static MakeWhereClause ( object>.IDictionary whereCols, IList sqlParams ) : string
whereCols object>.IDictionary Dictionary of object column values keyed by string column names.
sqlParams IList List to insert sql param values (in order) into.
Результат string

SqlParamsToString() публичный статический Метод

Converts the sql statement and parameters into a nicely formatted string for output in error messages or log statements.
public static SqlParamsToString ( string sql, IEnumerable sqlParams ) : string
sql string The SQL statement that needs the list of params.
sqlParams IEnumerable The list of params to format.
Результат string