C# Class Azavea.Open.DAO.SQL.SqlConnectionUtilities

This class holds static utility methods having to do with database access. The goal is twofold: 1: To reduce the number of lines of code required to to basic database stuff (if you're doing more complicated stuff, it may be appropriate to look at Azavea.Common.NHibernate and consider using NHibernate). 2: To ensure that connections are handled appropriately even in exception cases (I.E. they are closed and/or returned to the pool whether or not exceptions happen). Since no one likes obnoxiously long method names, "ExceptionSafe" has been abbreviated as "XSafe". There are two groups of methods, the "XSafe" query/command methods and the "DataSet" methods. The DataSet methods are provided primarily because some things (such as .NET controls) use DataSets directly. However, in general when writing new code you should use the XSafe methods, because they use DataReaders which are a faster way of accessing the database than DataSets. This class currently implements fairly primitive connection pooling. While .NET claims to do connection pooling for you, there is still a significant performance savings to be had by saving "DbConnection" objects and reusing them. The existing connection pooling basically saves one connection to any database you use this class to connect to. This achieves most of the savings that can be achieved with pooling, but if necessary a more complicated pooling scheme can be added in the future. Note that connection pooling is NOT used for all databases, since they may not support more than one "write" connection at a time.
Datei anzeigen Open project: azavea/net-dao

Public Methods

Method Description
CreateIndex ( AbstractSqlConnectionDescriptor connDesc, string indexName, bool isUnique, string tableName, IEnumerable columnNames ) : void

Creates an index on a database table.

CreateIndex ( AbstractSqlConnectionDescriptor connDesc, string indexName, string tableName, IEnumerable columnNames ) : void

Creates a non-unique index on a database table.

DropIndex ( AbstractSqlConnectionDescriptor connDesc, string indexName ) : bool

Drops the specified index.

GenerateMappingFromSchema ( AbstractSqlConnectionDescriptor connDesc, string tableName ) : ClassMapping

Generates a simplistic classmapping (without changing any column/field names) from a table's schema. Intended for times when you are transferring data without really using it, for example from a DB to a CSV. Will most likely only be useful for a DictionaryDAO since there is no defined .NET class to map to. All column names will be returned in caps.

GenerateMappingFromSchema ( AbstractSqlConnectionDescriptor connDesc, string tableName, IComparer columnSorter ) : ClassMapping

Generates a simplistic classmapping (without changing any column/field names) from a table's schema. Intended for times when you are transferring data without really using it, for example from a DB to a CSV. Will most likely only be useful for a DictionaryDAO since there is no defined .NET class to map to. All column names will be returned in caps.

GetSchema ( AbstractSqlConnectionDescriptor connDesc ) : DataTable

Similar to DbConnection.GetSchema, except this keeps the connection handling logic here in the utility class.

GetSchema ( AbstractSqlConnectionDescriptor connDesc, string name, string restrictions ) : DataTable

Similar to DbConnection.GetSchema, except this keeps the connection handling logic here in the utility class.

QueryForDataSet ( AbstractSqlConnectionDescriptor connDesc, string dataTableName, string sql, IEnumerable sqlParams ) : DataSet

Queries for data and populates the specified dataset. If you already have a dataset, use the QueryIntoDataSet method.

QueryIntoDataSet ( AbstractSqlConnectionDescriptor connDesc, string dataTableName, string sql, IEnumerable sqlParams, DataSet fillMe ) : void

Queries for data and populates the specified dataset. If you do not have a dataset already, call QueryForDataSet instead.

TestConnection ( AbstractSqlConnectionDescriptor connDesc ) : bool

Attempts to determine if a connection can be made using the specified connection string.

TruncateTable ( AbstractSqlConnectionDescriptor connDesc, string tableName ) : void

Truncates a table if supported by the DB, otherwise deletes all rows (which is effectively the same, but potentially a lot slower).

XSafeBoolQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : bool

Similar to the "XSafeQuery" method, except this executes a query that returns a single boolean.

XSafeBoolQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : bool

Similar to the "XSafeQuery" method, except this executes a query that returns a single boolean.

XSafeCommand ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : int

Similar to the "XSafeQuery" method, except this executes a non-query type SQL statement.

XSafeCommand ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : int

Similar to the "XSafeQuery" method, except this executes a non-query type SQL statement.

XSafeDateQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : System.DateTime

Similar to the "XSafeQuery" method, except this executes a query that returns a single DateTime (such as SELECT MAX(DateField)).

XSafeDateQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : System.DateTime

Similar to the "XSafeQuery" method, except this executes a query that returns a single DateTime (such as SELECT MAX(DateField)).

XSafeDoubleQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : double

Similar to the "XSafeQuery" method, except this executes a query that returns a single floating-point number (such as SELECT SUM(...)).

XSafeDoubleQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : double

Similar to the "XSafeQuery" method, except this executes a query that returns a single floating-point number (such as SELECT SUM(...)).

XSafeIntListQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : IList

Similar to the other XSafe methods, except this one returns a list of integers (for example, SELECT AGE FROM EMPLOYEES).

XSafeIntListQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : IList

Similar to the other XSafe methods, except this one returns a list of integers (for example, SELECT AGE FROM EMPLOYEES).

XSafeIntQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : int

Similar to the "XSafeQuery" method, except this executes a query that returns a single integer (such as SELECT COUNT).

XSafeIntQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : int

Similar to the "XSafeQuery" method, except this executes a query that returns a single integer (such as SELECT COUNT).

XSafeQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams, DataReaderDelegate invokeMe, Hashtable parameters ) : void

This provides a way to query the DB and do something with the results without having to copy the "try, open, try, execute, finally, close, finally, close" type logic in a bunch of places. This method correctly closes the objects used in the DB access in the event of an exception.

XSafeQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams, DataReaderDelegate invokeMe, Hashtable parameters ) : void

This provides a way to query the DB and do something with the results without having to copy the "try, open, try, execute, finally, close, finally, close" type logic in a bunch of places. This method correctly closes the objects used in the DB access in the event of an exception.

XSafeStringListQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : IList

Similar to the other XSafe methods, except this one returns a list of strings (for example, SELECT NAME FROM EMPLOYEES).

XSafeStringListQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : IList

Similar to the other XSafe methods, except this one returns a list of strings (for example, SELECT NAME FROM EMPLOYEES).

XSafeStringQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : string

Similar to the "XSafeQuery" method, except this executes a query that returns a single string.

XSafeStringQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : string

Similar to the "XSafeQuery" method, except this executes a query that returns a single string.

Private Methods

Method Description
ReadIntsFromQuery ( Hashtable parameters, IDataReader reader ) : void

Just reads the results, Convert.ToInt32's 'em, and puts them into the parameters hashtable as a list called 'results'. Nulls are ignored!

ReadStringsFromQuery ( Hashtable parameters, IDataReader reader ) : void

Just reads the results, ToString's 'em, and puts them into the parameters hashtable as a list called 'results'.

SetSQLOnCommand ( AbstractSqlConnectionDescriptor connDesc, IDbCommand cmd, string sql, IEnumerable sqlParams ) : void

Helper to set up a command with sql and parameters and other misc stuff.

XSafeScalarQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : object

Similar to the "XSafeQuery" method, except this executes a query that returns a single result.

Method Details

CreateIndex() public static method

Creates an index on a database table.
public static CreateIndex ( AbstractSqlConnectionDescriptor connDesc, string indexName, bool isUnique, string tableName, IEnumerable columnNames ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
indexName string Name of the index to create.
isUnique bool Is this a unique index?
tableName string What table to create the index on.
columnNames IEnumerable The columns included in the index.
return void

CreateIndex() public static method

Creates a non-unique index on a database table.
public static CreateIndex ( AbstractSqlConnectionDescriptor connDesc, string indexName, string tableName, IEnumerable columnNames ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
indexName string Name of the index to create.
tableName string What table to create the index on.
columnNames IEnumerable The columns included in the index.
return void

DropIndex() public static method

Drops the specified index.
public static DropIndex ( AbstractSqlConnectionDescriptor connDesc, string indexName ) : bool
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
indexName string The name of the index to remove.
return bool

GenerateMappingFromSchema() public static method

Generates a simplistic classmapping (without changing any column/field names) from a table's schema. Intended for times when you are transferring data without really using it, for example from a DB to a CSV. Will most likely only be useful for a DictionaryDAO since there is no defined .NET class to map to. All column names will be returned in caps.
public static GenerateMappingFromSchema ( AbstractSqlConnectionDescriptor connDesc, string tableName ) : ClassMapping
connDesc AbstractSqlConnectionDescriptor Connection descriptor for the database.
tableName string Name of the table to generate a mapping for.
return ClassMapping

GenerateMappingFromSchema() public static method

Generates a simplistic classmapping (without changing any column/field names) from a table's schema. Intended for times when you are transferring data without really using it, for example from a DB to a CSV. Will most likely only be useful for a DictionaryDAO since there is no defined .NET class to map to. All column names will be returned in caps.
public static GenerateMappingFromSchema ( AbstractSqlConnectionDescriptor connDesc, string tableName, IComparer columnSorter ) : ClassMapping
connDesc AbstractSqlConnectionDescriptor Connection descriptor for the database.
tableName string Name of the table to generate a mapping for.
columnSorter IComparer Since auto-generated column mappings are likely used for /// purposes such as exporting to a CSV, if you wish the columns /// to be sorted in some sort of order, you may provide an /// IComparer to do so. May be null.
return ClassMapping

GetSchema() public static method

Similar to DbConnection.GetSchema, except this keeps the connection handling logic here in the utility class.
public static GetSchema ( AbstractSqlConnectionDescriptor connDesc ) : DataTable
connDesc AbstractSqlConnectionDescriptor Connection descriptor for the database.
return System.Data.DataTable

GetSchema() public static method

Similar to DbConnection.GetSchema, except this keeps the connection handling logic here in the utility class.
public static GetSchema ( AbstractSqlConnectionDescriptor connDesc, string name, string restrictions ) : DataTable
connDesc AbstractSqlConnectionDescriptor Connection descriptor for the database.
name string The name of the type of object you want schema info on. /// For example, "Columns" to get info on the columns.
restrictions string A magic string array that means something to /// DbConnection.GetSchema. Should be a string array /// of the following restrictions: /// [0] = Catalog /// [1] = Owner /// [2] = Table /// [3] = TableType /// Any/all may be null.
return System.Data.DataTable

QueryForDataSet() public static method

Queries for data and populates the specified dataset. If you already have a dataset, use the QueryIntoDataSet method.
public static QueryForDataSet ( AbstractSqlConnectionDescriptor connDesc, string dataTableName, string sql, IEnumerable sqlParams ) : DataSet
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This will be /// used to get the database connection.
dataTableName string The name of the DataTable to put data into in the DataSet. /// May be null if you wish to use the default given by the DataAdapter.
sql string The parameterized SQL query (?'s for values).
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return System.Data.DataSet

QueryIntoDataSet() public static method

Queries for data and populates the specified dataset. If you do not have a dataset already, call QueryForDataSet instead.
public static QueryIntoDataSet ( AbstractSqlConnectionDescriptor connDesc, string dataTableName, string sql, IEnumerable sqlParams, DataSet fillMe ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This will be /// used to get the database connection.
dataTableName string The name of the DataTable to put data into in the DataSet. /// May be null if you wish to use the default given by the DataAdapter.
sql string The parameterized SQL query (?'s for values).
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
fillMe System.Data.DataSet The dataset to put data into. Must not be null.
return void

TestConnection() public static method

Attempts to determine if a connection can be made using the specified connection string.
public static TestConnection ( AbstractSqlConnectionDescriptor connDesc ) : bool
connDesc AbstractSqlConnectionDescriptor Connection descriptor to test.
return bool

TruncateTable() public static method

Truncates a table if supported by the DB, otherwise deletes all rows (which is effectively the same, but potentially a lot slower).
public static TruncateTable ( AbstractSqlConnectionDescriptor connDesc, string tableName ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
tableName string What table we want to blow away the contents of.
return void

XSafeBoolQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single boolean.
public static XSafeBoolQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : bool
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return bool

XSafeBoolQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single boolean.
public static XSafeBoolQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : bool
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return bool

XSafeCommand() public static method

Similar to the "XSafeQuery" method, except this executes a non-query type SQL statement.
public static XSafeCommand ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : int
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL statement to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return int

XSafeCommand() public static method

Similar to the "XSafeQuery" method, except this executes a non-query type SQL statement.
public static XSafeCommand ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : int
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL statement to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return int

XSafeDateQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single DateTime (such as SELECT MAX(DateField)).
public static XSafeDateQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : System.DateTime
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return System.DateTime

XSafeDateQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single DateTime (such as SELECT MAX(DateField)).
public static XSafeDateQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : System.DateTime
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return System.DateTime

XSafeDoubleQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single floating-point number (such as SELECT SUM(...)).
public static XSafeDoubleQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : double
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return double

XSafeDoubleQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single floating-point number (such as SELECT SUM(...)).
public static XSafeDoubleQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : double
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return double

XSafeIntListQuery() public static method

Similar to the other XSafe methods, except this one returns a list of integers (for example, SELECT AGE FROM EMPLOYEES).
public static XSafeIntListQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : IList
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return IList

XSafeIntListQuery() public static method

Similar to the other XSafe methods, except this one returns a list of integers (for example, SELECT AGE FROM EMPLOYEES).
public static XSafeIntListQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : IList
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return IList

XSafeIntQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single integer (such as SELECT COUNT).
public static XSafeIntQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : int
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return int

XSafeIntQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single integer (such as SELECT COUNT).
public static XSafeIntQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : int
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return int

XSafeQuery() public static method

This provides a way to query the DB and do something with the results without having to copy the "try, open, try, execute, finally, close, finally, close" type logic in a bunch of places. This method correctly closes the objects used in the DB access in the event of an exception.
public static XSafeQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams, DataReaderDelegate invokeMe, Hashtable parameters ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL statement to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
invokeMe DataReaderDelegate The method to delegate to. If null, nothing is /// done with the data reader and it is just closed.
parameters System.Collections.Hashtable The other parameters to the delegate, in whatever /// form makes sense for that delegate method.
return void

XSafeQuery() public static method

This provides a way to query the DB and do something with the results without having to copy the "try, open, try, execute, finally, close, finally, close" type logic in a bunch of places. This method correctly closes the objects used in the DB access in the event of an exception.
public static XSafeQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams, DataReaderDelegate invokeMe, Hashtable parameters ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL statement to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
invokeMe DataReaderDelegate The method to delegate to. If null, nothing is /// done with the data reader and it is just closed.
parameters System.Collections.Hashtable The other parameters to the delegate, in whatever /// form makes sense for that delegate method.
return void

XSafeStringListQuery() public static method

Similar to the other XSafe methods, except this one returns a list of strings (for example, SELECT NAME FROM EMPLOYEES).
public static XSafeStringListQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : IList
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return IList

XSafeStringListQuery() public static method

Similar to the other XSafe methods, except this one returns a list of strings (for example, SELECT NAME FROM EMPLOYEES).
public static XSafeStringListQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : IList
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return IList

XSafeStringQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single string.
public static XSafeStringQuery ( AbstractSqlConnectionDescriptor connDesc, SqlTransaction transaction, string sql, IEnumerable sqlParams ) : string
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
transaction SqlTransaction The transaction to do this as part of.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return string

XSafeStringQuery() public static method

Similar to the "XSafeQuery" method, except this executes a query that returns a single string.
public static XSafeStringQuery ( AbstractSqlConnectionDescriptor connDesc, string sql, IEnumerable sqlParams ) : string
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
sql string The SQL query to execute.
sqlParams IEnumerable A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters.
return string