[Adapdev-commits] Adapdev/src/Adapdev.Data AbstractDAO.cs,1.1.1.1,1.2
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-07-21 23:29:32
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11796/src/Adapdev.Data Modified Files: AbstractDAO.cs Log Message: Index: AbstractDAO.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Data/AbstractDAO.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AbstractDAO.cs 28 Feb 2005 01:31:45 -0000 1.1.1.1 --- AbstractDAO.cs 21 Jul 2005 23:29:21 -0000 1.2 *************** *** 13,17 **** /// Data Access Object. /// </summary> ! public abstract class AbstractDAO : MarshalByRefObject, IDbDataAccessObject, IDbDataSetAccessObject, IDataReaderMapper { private DbProviderType provider = DbProviderType.SQLSERVER; --- 13,17 ---- /// Data Access Object. /// </summary> ! public abstract class AbstractDAO : MarshalByRefObject, IDbDataAccessObject, IDbDataSetAccessObject, IDataReaderMapper, IDisposable { private DbProviderType provider = DbProviderType.SQLSERVER; *************** *** 19,22 **** --- 19,24 ---- private string connectionString = ""; private string table = ""; + private bool disposed = false; + #region Constructors *************** *** 284,287 **** --- 286,312 ---- /// <param name="id">The id for the record to select</param> /// <returns></returns> + public object SelectById(object id) + { + return this.SelectOne(id); + } + + /// <summary> + /// Selects a specific record, using the passed in id + /// </summary> + /// <param name="id">The id for the record to select</param> + /// <param name="connection">The open IDbConnection to use</param> + /// <returns></returns> + public object SelectById(object id, IDbConnection connection) + { + return this.SelectOne(id, connection); + } + + /// <summary> + /// Selects a specific record, using the passed in id + /// </summary> + /// <param name="id">The id for the record to select</param> + /// <returns></returns> + /// + [Obsolete("Deprecated. Please use SelectById")] public object SelectOne(object id) { *************** *** 301,304 **** --- 326,330 ---- /// <param name="conn">The open IDbConnection to use</param> /// <returns></returns> + [Obsolete("Deprecated. Please use SelectById")] public object SelectOne(object id, IDbConnection conn) { *************** *** 468,471 **** --- 494,518 ---- /// Creates a DataSet using the given command /// </summary> + /// <param name="sql">The sql command to execute</param> + /// <returns></returns> + public DataSet SelectDS(string sql) + { + return this.SelectDS(this.CreateCommand(sql)); + } + + /// <summary> + /// Creates a DataSet using the given command + /// </summary> + /// <param name="sql">The sql command to execute</param> + /// <param name="conn">The open IDbConnection to use</param> + /// <returns></returns> + public DataSet SelectDS(string sql, IDbConnection conn) + { + return this.GetDataSet(this.CreateCommand(sql), conn); + } + + /// <summary> + /// Creates a DataSet using the given command + /// </summary> /// <param name="cmd">The command to execute</param> /// <param name="conn">The open IDbConnection to use</param> *************** *** 481,484 **** --- 528,554 ---- /// <param name="id">The id of the record to select</param> /// <returns></returns> + public DataSet SelectDatasetById(object id) + { + return this.SelectOneDS(id); + } + + /// <summary> + /// Returns one record wrapped in a DataSet + /// </summary> + /// <param name="id">The id of the record to select</param> + /// <param name="conn">The open IDbConnection to use</param> + /// <returns></returns> + public DataSet SelectDatasetById(object id, IDbConnection conn) + { + return this.SelectOneDS(id, conn); + } + + /// <summary> + /// Returns one record wrapped in a DataSet + /// </summary> + /// <param name="id">The id of the record to select</param> + /// <returns></returns> + /// + [Obsolete("Deprecated. Please use SelectDataSetById")] public DataSet SelectOneDS(object id) { *************** *** 492,495 **** --- 562,566 ---- /// <param name="conn">The open IDbConnection to use</param> /// <returns></returns> + [Obsolete("Deprecated. Please use SelectDataSetById")] public DataSet SelectOneDS(object id, IDbConnection conn) { *************** *** 664,667 **** --- 735,748 ---- /// </summary> /// <param name="cmd">The command to execute</param> + /// <returns></returns> + protected DataSet CreateDataSet(string cmd) + { + return DbProviderFactory.CreateDataSet(this.connectionString, this.CreateCommand(cmd), this.provider); + } + + /// <summary> + /// Creates a DataSet, using the given command + /// </summary> + /// <param name="cmd">The command to execute</param> /// <param name="conn">The open connection to use</param> /// <returns></returns> *************** *** 775,778 **** --- 856,895 ---- #endregion + + #region IDisposable Members + + public void Dispose() + { + Dispose(true); + // Take yourself off the Finalization queue + // to prevent finalization code for this object + // from executing a second time. + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + // Check to see if Dispose has already been called. + if(!this.disposed) + { + // If disposing equals true, dispose all managed + // and unmanaged resources. + if(disposing) + { + // Dispose managed resources. + } + } + disposed = true; + } + + ~AbstractDAO() + { + // Do not re-create Dispose clean-up code here. + // Calling Dispose(false) is optimal in terms of + // readability and maintainability. + Dispose(false); + } + + #endregion } } \ No newline at end of file |