Class DBHelper
The DataHelper class is intended to encapsulate high performance, scalable best practices for
common uses of SqlClient.
Inheritance
System.Object
DBHelper
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: Mediachase.MetaDataPlus.dll
Version: 10.8.0
public sealed class DBHelper
Methods
Declaration
public static object DBNull2Null(object value)
Parameters
Type |
Name |
Description |
System.Object |
value |
|
Returns
Type |
Description |
System.Object |
|
Declaration
public static object DBNull2Null(object value, object defaultValue)
Parameters
Type |
Name |
Description |
System.Object |
value |
|
System.Object |
defaultValue |
|
Returns
Type |
Description |
System.Object |
|
ExecuteDataSet(MetaDataContext, CommandType, String)
Declaration
public static DataResult ExecuteDataSet(MetaDataContext context, CommandType commandType, string commandText)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
Returns
ExecuteDataSet(MetaDataContext, CommandType, String, DataParameter[])
Declaration
public static DataResult ExecuteDataSet(MetaDataContext context, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
Declaration
public static DataResult ExecuteDataSet(string connectionString, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
ExecuteDataTable(MetaDataContext, CommandType, String)
Declaration
public static DataTable ExecuteDataTable(MetaDataContext context, CommandType commandType, string commandText)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
Returns
Type |
Description |
System.Data.DataTable |
|
ExecuteDataTable(MetaDataContext, CommandType, String, DataParameter[])
Declaration
public static DataTable ExecuteDataTable(MetaDataContext context, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
Type |
Description |
System.Data.DataTable |
|
ExecuteDataTable(MetaDataContext, CommandType, String, Int32, DataParameter[])
Declaration
public static DataTable ExecuteDataTable(MetaDataContext context, CommandType commandType, string commandText, int commandTimeout, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
System.Int32 |
commandTimeout |
|
DataParameter[] |
commandParameters |
|
Returns
Type |
Description |
System.Data.DataTable |
|
Declaration
public static DataTable ExecuteDataTable(string connectionString, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
Type |
Description |
System.Data.DataTable |
|
Declaration
public static DataTable ExecuteDataTable(string connectionString, CommandType commandType, string commandText, int commandTimeout, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
System.Int32 |
commandTimeout |
|
DataParameter[] |
commandParameters |
|
Returns
Type |
Description |
System.Data.DataTable |
|
ExecuteNonQuery(MetaDataContext, CommandType, String)
Declaration
public static DataResult ExecuteNonQuery(MetaDataContext context, CommandType commandType, string commandText)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
Returns
ExecuteNonQuery(MetaDataContext, CommandType, String, DataParameter[])
Declaration
public static DataResult ExecuteNonQuery(MetaDataContext context, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
ExecuteNonQuery(MetaDataContext, CommandType, String, Int32, DataParameter[])
Declaration
public static DataResult ExecuteNonQuery(MetaDataContext context, CommandType commandType, string commandText, int commandTimeout, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
System.Int32 |
commandTimeout |
|
DataParameter[] |
commandParameters |
|
Returns
Execute a DataCommand (that returns no resultset and takes no parameters) against the database specified in
the connection string.
Declaration
public static DataResult ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
a valid connection string for a SqlConnection
|
System.Data.CommandType |
commandType |
the CommandType (stored procedure, text, etc.)
|
System.String |
commandText |
the stored procedure name or T-SQL command
|
Returns
Type |
Description |
DataResult |
an int representing the number of rows affected by the command
|
Execute a DataCommand (that returns no resultset) against the specified SqlConnection
using the provided parameters.
Declaration
public static DataResult ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
The connection string.
|
System.Data.CommandType |
commandType |
the CommandType (stored procedure, text, etc.)
|
System.String |
commandText |
the stored procedure name or T-SQL command
|
DataParameter[] |
commandParameters |
an array of SqlParamters used to execute the command
|
Returns
Type |
Description |
DataResult |
an int representing the number of rows affected by the command
|
Execute a DataCommand (that returns no resultset) against the specified SqlConnection
using the provided parameters.
Declaration
public static DataResult ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, int commandTimeout, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
The connection string.
|
System.Data.CommandType |
commandType |
the CommandType (stored procedure, text, etc.)
|
System.String |
commandText |
the stored procedure name or T-SQL command
|
System.Int32 |
commandTimeout |
The wait time before terminating the attempt to execute a command and generating an error.
|
DataParameter[] |
commandParameters |
an array of SqlParamters used to execute the command
|
Returns
Type |
Description |
DataResult |
an int representing the number of rows affected by the command
|
ExecuteReader(MetaDataContext, CommandType, String)
Declaration
public static DataResult ExecuteReader(MetaDataContext context, CommandType commandType, string commandText)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
Returns
ExecuteReader(MetaDataContext, CommandType, String, DataParameter[])
Declaration
public static DataResult ExecuteReader(MetaDataContext context, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
Create and prepare a DataCommand, and call ExecuteReader with the appropriate CommandBehavior.
Declaration
public static DataResult ExecuteReader(string connectionString, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
The connection string.
|
System.Data.CommandType |
commandType |
the CommandType (stored procedure, text, etc.)
|
System.String |
commandText |
the stored procedure name or T-SQL command
|
DataParameter[] |
commandParameters |
an array of DataParameters to be associated with the command or 'null' if no parameters are required
|
Returns
Type |
Description |
DataResult |
IDataReader containing the results of the command
|
ExecuteScalar(MetaDataContext, CommandType, String, DataParameter[])
Declaration
public static DataResult ExecuteScalar(MetaDataContext context, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Data.CommandType |
commandType |
|
System.String |
commandText |
|
DataParameter[] |
commandParameters |
|
Returns
Execute a DataCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in
the connection string.
Declaration
public static DataResult ExecuteScalar(string connectionString, CommandType commandType, string commandText)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
a valid connection string for a SqlConnection
|
System.Data.CommandType |
commandType |
the CommandType (stored procedure, text, etc.)
|
System.String |
commandText |
the stored procedure name or T-SQL command
|
Returns
Type |
Description |
DataResult |
an object containing the value in the 1x1 resultset generated by the command
|
Execute a DataCommand (that returns a 1x1 resultset) against the specified SqlConnection
using the provided parameters.
Declaration
public static DataResult ExecuteScalar(string connectionString, CommandType commandType, string commandText, params DataParameter[] commandParameters)
Parameters
Type |
Name |
Description |
System.String |
connectionString |
The connection string.
|
System.Data.CommandType |
commandType |
the CommandType (stored procedure, text, etc.)
|
System.String |
commandText |
the stored procedure name or T-SQL command
|
DataParameter[] |
commandParameters |
an array of SqlParamters used to execute the command
|
Returns
Type |
Description |
DataResult |
an object containing the value in the 1x1 resultset generated by the command
|
ExecuteScript(MetaDataContext, String)
Declaration
public static void ExecuteScript(MetaDataContext context, string script)
Parameters
GetMetaKey(MetaDataContext, Int32, Int32, Int32)
Declaration
public static int GetMetaKey(MetaDataContext context, int metaObjectId, int metaClassId, int metaFieldId)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Int32 |
metaObjectId |
|
System.Int32 |
metaClassId |
|
System.Int32 |
metaFieldId |
|
Returns
Type |
Description |
System.Int32 |
|
GetMetaKey(MetaDataContext, Int32, Int32, Int32, String)
Declaration
public static int GetMetaKey(MetaDataContext context, int metaObjectId, int metaClassId, int metaFieldId, string language)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Int32 |
metaObjectId |
|
System.Int32 |
metaClassId |
|
System.Int32 |
metaFieldId |
|
System.String |
language |
|
Returns
Type |
Description |
System.Int32 |
|
GetMetaKey(MetaDataContext, Int32, Nullable<Int32>, Int32, Int32, String)
Declaration
public static int GetMetaKey(MetaDataContext context, int metaObjectId, int? workId, int metaClassId, int metaFieldId, string language)
Parameters
Type |
Name |
Description |
MetaDataContext |
context |
|
System.Int32 |
metaObjectId |
|
System.Nullable<System.Int32> |
workId |
|
System.Int32 |
metaClassId |
|
System.Int32 |
metaFieldId |
|
System.String |
language |
|
Returns
Type |
Description |
System.Int32 |
|
Declaration
public static object Null2DBNull(object value)
Parameters
Type |
Name |
Description |
System.Object |
value |
|
Returns
Type |
Description |
System.Object |
|