using System; using System.Data; namespace GZTW.Data { /// /// Represents a wrapper for types. This class is abstract. /// /// public abstract class DBCommandWrapper : MarshalByRefObject, IDisposable { /// /// When overridden in a derived class, gets the underlying . /// /// /// The underlying . The default is . /// public abstract IDbCommand Command { get; } /// /// When overridden in a derived class, gets or sets the rows affected by this command. /// /// /// The rows affected by this command. /// public abstract int RowsAffected { get; set; } /// /// When overridden in a derived class, gets or sets the wait time before terminating the attempt to execute a command and generating an error. /// /// /// The wait time before terminating the attempt to execute a command and generating an error. /// public abstract int CommandTimeout { get; set; } /// /// When overridden in a derived class, adds a new instance of an object to the command. /// /// The name of the parameter. /// One of the values. /// The maximum size of the data within the column. /// One of the values. /// Avalue indicating whether the parameter accepts null values. /// The maximum number of digits used to represent the . /// The number of decimal places to which is resolved. /// The name of the source column mapped to the DataSet and used for loading or returning the . /// One of the values. /// The value of the parameter. public abstract void AddParameter(string name, DbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value); /// /// When overridden in a derived class, adds a new instance of an object to the command. /// /// The name of the parameter. /// One of the values. /// One of the values. /// The name of the source column mapped to the DataSet and used for loading or returning the . /// One of the values. /// The value of the parameter. public abstract void AddParameter(string name, DbType dbType, ParameterDirection direction, string sourceColumn, DataRowVersion sourceVersion, object value); /// /// When overridden in a derived class, adds a new instance of an object to the command set as value of Output. /// /// The name of the parameter. /// One of the values. /// The maximum size of the data within the column. public abstract void AddOutParameter(string name, DbType dbType, int size); /// /// When overridden in a derived class, adds a new instance of an object to the command set as value of Input. /// /// The name of the parameter. /// One of the values. /// /// This version of the method is used when you can have the same parameter object multiple times with different values. /// public abstract void AddInParameter(string name, DbType dbType); /// /// When overridden in a derived class, adds a new instance of an object to the command set as value of Input. /// /// The name of the parameter. /// One of the values. /// The value of the parameter. public abstract void AddInParameter(string name, DbType dbType, object value); /// /// Used for special handling of large string values /// in each type of database. /// When overridden in a derived class, adds a new instance of an object to the command set as value of Input. /// /// The name of the parameter. /// The value of the parameter. public abstract void AddLargeStringInParameter(string name, object value); /// /// When overridden in a derived class, adds a new instance of an object to the command set as value of Input. /// /// The name of the parameter. /// One of the values. /// The name of the source column mapped to the DataSet and used for loading or returning the value. /// One of the values. public abstract void AddInParameter(string name, DbType dbType, string sourceColumn, DataRowVersion sourceVersion); /// /// When overridden in a derived class, returns the value of the parameter for the given . /// /// The name of the parameter to get the value. /// The value of the parameter. public abstract object GetParameterValue(string name); /// /// When overridden in a derived class, sets the value of a parameter for the given . /// /// The name of the parameter to set the value. /// The new value of the parameter. public abstract void SetParameterValue(string name, object value); /// /// When overridden in a derived class, sets the value of a parameter for the given . /// /// The index of the parameter to set the value. /// The new value of the parameter. public abstract void SetParameterValue(int index, object value); /// /// Populate the parameter collection for a stored procedure by querying the database /// or loading a cached parameter set. /// internal void DiscoverParameters(char parameterToken) { DoDiscoverParameters(parameterToken); } /// /// Determine if the parameters collection needs to be populated /// using parameter discovery /// /// true if parameter discovery is needed internal bool IsFurtherPreparationNeeded() { return DoIsFurtherPreparationNeeded(); } /// /// Assign values to parameters in positional orders /// internal void AssignParameterValues() { DoAssignParameterValues(); } /// /// When overridden in a derived class, discover the parameters for a stored procedure using a separate connection and command. /// /// The parameter delimeter for database commands. protected abstract void DoDiscoverParameters(char parameterToken); /// /// When overridden in a derived class, assign the values provided by a user to the command parameters discovered in positional order. /// /// /// The number of parameters does not match number of values for stored procedure. /// protected abstract void DoAssignParameterValues(); /// /// When overridden in a derived class, determine if a stored procedure is using parameter discovery. /// /// /// if further preparation is needed. /// protected abstract bool DoIsFurtherPreparationNeeded(); /// /// When overridden in a derived class, clean up resources. /// public abstract void Dispose(); } }