C# Class CustomerService.DBUtility.SqlHelper

The SqlHelper class is intended to encapsulate high performance, scalable best practices for common uses of SqlClient.
Afficher le fichier Open project: NanQi/demo

Méthodes publiques

Свойство Type Description
ConnectionStringInventoryDistributedTransaction string
ConnectionStringLocalTransaction string
ConnectionStringOrderDistributedTransaction string
ConnectionStringProfile string

Méthodes publiques

Méthode Description
CacheParameters ( string cacheKey ) : void

add parameter array to the cache

ExecuteNonQuery ( SqlConnection connection, CommandType cmdType, string cmdText ) : int

Execute a SqlCommand (that returns no resultset) against an existing database connection using the provided parameters.

e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

ExecuteNonQuery ( SqlTransaction trans, CommandType cmdType, string cmdText ) : int

Execute a SqlCommand (that returns no resultset) using an existing SQL Transaction using the provided parameters.

e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

ExecuteNonQuery ( string connectionString, CommandType cmdType, string cmdText ) : int

Execute a SqlCommand (that returns no resultset) against the database specified in the connection string using the provided parameters.

e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

ExecuteReader ( string connectionString, CommandType cmdType, string cmdText ) : System.Data.SqlClient.SqlDataReader

Execute a SqlCommand that returns a resultset against the database specified in the connection string using the provided parameters.

e.g.: SqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

ExecuteScalar ( SqlConnection connection, CommandType cmdType, string cmdText ) : object

Execute a SqlCommand that returns the first column of the first record against an existing database connection using the provided parameters.

e.g.: Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

ExecuteScalar ( string connectionString, CommandType cmdType, string cmdText ) : object

Execute a SqlCommand that returns the first column of the first record against the database specified in the connection string using the provided parameters.

e.g.: Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

GetCachedParameters ( string cacheKey ) : System.Data.SqlClient.SqlParameter[]

Retrieve cached parameters

Private Methods

Méthode Description
PrepareCommand ( SqlCommand cmd, SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter cmdParms ) : void

Prepare a command for execution

Method Details

CacheParameters() public static méthode

add parameter array to the cache
public static CacheParameters ( string cacheKey ) : void
cacheKey string Key to the parameter cache
Résultat void

ExecuteNonQuery() public static méthode

Execute a SqlCommand (that returns no resultset) against an existing database connection using the provided parameters.
e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteNonQuery ( SqlConnection connection, CommandType cmdType, string cmdText ) : int
connection System.Data.SqlClient.SqlConnection
cmdType CommandType
cmdText string
Résultat int

ExecuteNonQuery() public static méthode

Execute a SqlCommand (that returns no resultset) using an existing SQL Transaction using the provided parameters.
e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteNonQuery ( SqlTransaction trans, CommandType cmdType, string cmdText ) : int
trans System.Data.SqlClient.SqlTransaction an existing sql transaction
cmdType CommandType
cmdText string
Résultat int

ExecuteNonQuery() public static méthode

Execute a SqlCommand (that returns no resultset) against the database specified in the connection string using the provided parameters.
e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteNonQuery ( string connectionString, CommandType cmdType, string cmdText ) : int
connectionString string a valid connection string for a SqlConnection
cmdType CommandType
cmdText string
Résultat int

ExecuteReader() public static méthode

Execute a SqlCommand that returns a resultset against the database specified in the connection string using the provided parameters.
e.g.: SqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteReader ( string connectionString, CommandType cmdType, string cmdText ) : System.Data.SqlClient.SqlDataReader
connectionString string a valid connection string for a SqlConnection
cmdType CommandType
cmdText string
Résultat System.Data.SqlClient.SqlDataReader

ExecuteScalar() public static méthode

Execute a SqlCommand that returns the first column of the first record against an existing database connection using the provided parameters.
e.g.: Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteScalar ( SqlConnection connection, CommandType cmdType, string cmdText ) : object
connection System.Data.SqlClient.SqlConnection
cmdType CommandType
cmdText string
Résultat object

ExecuteScalar() public static méthode

Execute a SqlCommand that returns the first column of the first record against the database specified in the connection string using the provided parameters.
e.g.: Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteScalar ( string connectionString, CommandType cmdType, string cmdText ) : object
connectionString string a valid connection string for a SqlConnection
cmdType CommandType
cmdText string
Résultat object

GetCachedParameters() public static méthode

Retrieve cached parameters
public static GetCachedParameters ( string cacheKey ) : System.Data.SqlClient.SqlParameter[]
cacheKey string key used to lookup parameters
Résultat System.Data.SqlClient.SqlParameter[]

Property Details

ConnectionStringInventoryDistributedTransaction public_oe static_oe property

public static string ConnectionStringInventoryDistributedTransaction
Résultat string

ConnectionStringLocalTransaction public_oe static_oe property

public static string ConnectionStringLocalTransaction
Résultat string

ConnectionStringOrderDistributedTransaction public_oe static_oe property

public static string ConnectionStringOrderDistributedTransaction
Résultat string

ConnectionStringProfile public_oe static_oe property

public static string ConnectionStringProfile
Résultat string