/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">SmartMassEmail.Entities.EmailMessageDetail object to update.</param>
		/// <remarks>
		///		After updating the datasource, the SmartMassEmail.Entities.EmailMessageDetail object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, SmartMassEmail.Entities.EmailMessageDetail entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@ID", DbType.Guid, entity.ID );
			database.AddInParameter(commandWrapper, "@OriginalID", DbType.Guid, entity.OriginalID);
			database.AddInParameter(commandWrapper, "@ChangeStamp", DbType.DateTime, entity.ChangeStamp );
			database.AddInParameter(commandWrapper, "@IsBinary", DbType.Int32, entity.IsBinary );
			database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name );
			database.AddInParameter(commandWrapper, "@BinaryData", DbType.Binary, entity.BinaryData );
			database.AddInParameter(commandWrapper, "@StringData", DbType.AnsiString, entity.StringData );
			database.AddInParameter(commandWrapper, "@EmailMessageID", DbType.Guid, entity.EmailMessageID );
			
			int results = 0;
			
			
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalID = entity.ID;
			
			entity.AcceptChanges();
	
			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">SmartMassEmail.Entities.EmailMessage object to update.</param>
		/// <remarks>
		///		After updating the datasource, the SmartMassEmail.Entities.EmailMessage object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, SmartMassEmail.Entities.EmailMessage entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessage_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@ID", DbType.Guid, entity.ID );
			database.AddInParameter(commandWrapper, "@OriginalID", DbType.Guid, entity.OriginalID);
			database.AddInParameter(commandWrapper, "@ChangeStamp", DbType.DateTime, entity.ChangeStamp );
			database.AddInParameter(commandWrapper, "@Priority", DbType.Int32, entity.Priority );
			database.AddInParameter(commandWrapper, "@Status", DbType.Int32, entity.Status );
			database.AddInParameter(commandWrapper, "@NumberOfRetry", DbType.Int32, entity.NumberOfRetry );
			database.AddInParameter(commandWrapper, "@RetryTime", DbType.DateTime, entity.RetryTime );
			database.AddInParameter(commandWrapper, "@MaximumRetry", DbType.Int32, entity.MaximumRetry );
			database.AddInParameter(commandWrapper, "@ExpiryDatetime", DbType.DateTime, entity.ExpiryDatetime );
			database.AddInParameter(commandWrapper, "@ArrivedDateTime", DbType.DateTime, entity.ArrivedDateTime );
			database.AddInParameter(commandWrapper, "@SenderInfo", DbType.AnsiString, entity.SenderInfo );
			database.AddInParameter(commandWrapper, "@EmailTo", DbType.AnsiString, entity.EmailTo );
			database.AddInParameter(commandWrapper, "@EmailFrom", DbType.AnsiString, entity.EmailFrom );
            database.AddInParameter(commandWrapper, "@EmailSubject", SqlDbType.NVarChar, entity.EmailSubject);
			database.AddInParameter(commandWrapper, "@EmailBody", SqlDbType.NText, entity.EmailBody );
			database.AddInParameter(commandWrapper, "@EmailCC", DbType.AnsiString, entity.EmailCC );
			database.AddInParameter(commandWrapper, "@EmailBCC", DbType.AnsiString, entity.EmailBCC );
			database.AddInParameter(commandWrapper, "@IsHtml", DbType.Boolean, entity.IsHtml );
			
			int results = 0;
			
			
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalID = entity.ID;
			
			entity.AcceptChanges();
	
			return Convert.ToBoolean(results);
		}