/// <summary> /// Deletes a record from the MailMessage table by MailMessageId. /// </summary> /// <param name="MailMessageId">A key field.</param> /// <param name="transaction"></param> public void Delete(IdType mailMessageId, IDbTransaction transaction) { // Create and execute the command IDbCommand cmd = GetDbCommand(CONNECTION_STRING_KEY, "spMailMessage_Delete", CommandType.StoredProcedure, COMMAND_TIMEOUT, transaction); // Create and append the parameters cmd.Parameters.Add(CreateDataParameter("@MailMessageId", DbType.Int32, ParameterDirection.Input, mailMessageId.IsValid ? mailMessageId.ToInt32() as Object : DBNull.Value)); // Execute the query and return the result cmd.ExecuteNonQuery(); // do not close the connection if it is part of a transaction if (transaction == null) { cmd.Connection.Close(); } }
/// <summary> /// Finds a MailMessage entity using it's primary key. /// </summary> /// <param name="MailMessageId">A key field.</param> /// <returns>A MailMessage object.</returns> /// <exception cref="Spring2.Core.DAO.FinderException">Thrown when no entity exists witht he specified primary key..</exception> public MailMessage Load(IdType mailMessageId) { SqlFilter filter = new SqlFilter(); filter.And(new SqlEqualityPredicate("MailMessageId", EqualityOperatorEnum.Equal, mailMessageId.IsValid ? mailMessageId.ToInt32() as Object : DBNull.Value)); IDataReader dataReader = GetListReader(CONNECTION_STRING_KEY, VIEW, filter, null); return(GetDataObject(dataReader)); }