/*
File Generated by NetTiers templates [www.nettiers.com]
Generated on : Friday, 1 September 2006
Important: Do not modify this file. Edit the file SqlEmailMessageDetailProvider.cs instead.
*/
#region using directives
using System;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
using SmartMassEmail.Entities;
using SmartMassEmail.Data;
using SmartMassEmail.Data.Bases;
#endregion
namespace SmartMassEmail.Data.SqlClient
{
///<summary>
/// This class is the SqlClient Data Access Logic Component implementation for the <see cref="EmailMessageDetail"/> entity.
///</summary>
public partial class SqlEmailMessageDetailProviderBase : EmailMessageDetailProviderBase
{
#region Declarations
string _connectionString;
bool _useStoredProcedure;
string _providerInvariantName;
#endregion "Declarations"
#region Constructors
/// <summary>
/// Creates a new <see cref="SqlEmailMessageDetailProviderBase"/> instance.
/// </summary>
public SqlEmailMessageDetailProviderBase()
{
}
/// <summary>
/// Creates a new <see cref="SqlEmailMessageDetailProviderBase"/> instance.
/// Uses connection string to connect to datasource.
/// </summary>
/// <param name="connectionString">The connection string to the database.</param>
/// <param name="useStoredProcedure">A boolean value that indicates if we use the stored procedures or embedded queries.</param>
/// <param name="providerInvariantName">Name of the invariant provider use by the DbProviderFactory.</param>
public SqlEmailMessageDetailProviderBase(string connectionString, bool useStoredProcedure, string providerInvariantName)
{
this._connectionString = connectionString;
this._useStoredProcedure = useStoredProcedure;
this._providerInvariantName = providerInvariantName;
}
#endregion "Constructors"
#region Public properties
/// <summary>
/// Gets or sets the connection string.
/// </summary>
/// <value>The connection string.</value>
public string ConnectionString
{
get {return this._connectionString;}
set {this._connectionString = value;}
}
/// <summary>
/// Gets or sets a value indicating whether to use stored procedures.
/// </summary>
/// <value><c>true</c> if we choose to use use stored procedures; otherwise, <c>false</c>.</value>
public bool UseStoredProcedure
{
get {return this._useStoredProcedure;}
set {this._useStoredProcedure = value;}
}
/// <summary>
/// Gets or sets the invariant provider name listed in the DbProviderFactories machine.config section.
/// </summary>
/// <value>The name of the provider invariant.</value>
public string ProviderInvariantName
{
get { return this._providerInvariantName; }
set { this._providerInvariantName = value; }
}
#endregion
#region Get Many To Many Relationship Functions
#endregion
#region Delete Functions
/// <summary>
/// Deletes a row from the DataSource.
/// </summary>
/// <param name="id">. Primary Key.</param>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <remarks>Deletes based on primary key(s).</remarks>
/// <returns>Returns true if operation suceeded.</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 Delete(TransactionManager transactionManager, System.Guid id)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_Delete", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@ID", DbType.Guid, id);
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)
{
string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(EmailMessageDetail)
,id);
EntityManager.StopTracking(entityKey);
}
if (results == 0)
{
//throw new DataException("The record has been already deleted.");
return false;
}
return Convert.ToBoolean(results);
}//end Delete
#endregion
#region Find Functions
/// <summary>
/// Returns rows meeting the whereclause condition from the DataSource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out. The number of rows that match this query.</param>
/// <remarks>Operators must be capitalized (OR, AND)</remarks>
/// <returns>Returns a typed collection of SmartMassEmail.Entities.EmailMessageDetail objects.</returns>
public override SmartMassEmail.Entities.TList<EmailMessageDetail> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count)
{
count = -1;
if (whereClause.IndexOf(";") > -1)
return new SmartMassEmail.Entities.TList<EmailMessageDetail>();
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_Find", _useStoredProcedure);
bool searchUsingOR = false;
if (whereClause.IndexOf("OR") > 0) // did they want to do "a=b OR c=d OR..."?
searchUsingOR = true;
database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR);
database.AddInParameter(commandWrapper, "@ID", DbType.Guid, DBNull.Value);
database.AddInParameter(commandWrapper, "@ChangeStamp", DbType.DateTime, DBNull.Value);
database.AddInParameter(commandWrapper, "@IsBinary", DbType.Int32, DBNull.Value);
database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, DBNull.Value);
database.AddInParameter(commandWrapper, "@BinaryData", DbType.Binary, DBNull.Value);
database.AddInParameter(commandWrapper, "@StringData", DbType.AnsiString, DBNull.Value);
database.AddInParameter(commandWrapper, "@EmailMessageID", DbType.Guid, DBNull.Value);
// replace all instances of 'AND' and 'OR' because we already set searchUsingOR
whereClause = whereClause.Replace("AND", "|").Replace("OR", "|") ;
string[] clauses = whereClause.ToLower().Split('|');
// Here's what's going on below: Find a field, then to get the value we
// drop the field name from the front, trim spaces, drop the '=' sign,
// trim more spaces, and drop any outer single quotes.
// Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'"
char[] equalSign = {'='};
char[] singleQuote = {'\''};
foreach (string clause in clauses)
{
if (clause.Trim().StartsWith("id ") || clause.Trim().StartsWith("id="))
{
database.SetParameterValue(commandWrapper, "@ID", new Guid(
clause.Replace("id","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote)));
continue;
}
if (clause.Trim().StartsWith("changestamp ") || clause.Trim().StartsWith("changestamp="))
{
database.SetParameterValue(commandWrapper, "@ChangeStamp",
clause.Replace("changestamp","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote));
continue;
}
if (clause.Trim().StartsWith("isbinary ") || clause.Trim().StartsWith("isbinary="))
{
database.SetParameterValue(commandWrapper, "@IsBinary",
clause.Replace("isbinary","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote));
continue;
}
if (clause.Trim().StartsWith("name ") || clause.Trim().StartsWith("name="))
{
database.SetParameterValue(commandWrapper, "@Name",
clause.Replace("name","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote));
continue;
}
if (clause.Trim().StartsWith("binarydata ") || clause.Trim().StartsWith("binarydata="))
{
database.SetParameterValue(commandWrapper, "@BinaryData",
clause.Replace("binarydata","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote));
continue;
}
if (clause.Trim().StartsWith("stringdata ") || clause.Trim().StartsWith("stringdata="))
{
database.SetParameterValue(commandWrapper, "@StringData",
clause.Replace("stringdata","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote));
continue;
}
if (clause.Trim().StartsWith("emailmessageid ") || clause.Trim().StartsWith("emailmessageid="))
{
database.SetParameterValue(commandWrapper, "@EmailMessageID", new Guid(
clause.Replace("emailmessageid","").Trim().TrimStart(equalSign).Trim().Trim(singleQuote)));
continue;
}
throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause);
}
IDataReader reader = null;
//Create Collection
SmartMassEmail.Entities.TList<EmailMessageDetail> rows = new SmartMassEmail.Entities.TList<EmailMessageDetail>();
try
{
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
Fill(reader, rows, start, pageLength);
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
}
finally
{
if (reader != null)
reader.Close();
}
return rows;
}
#endregion "Find Functions"
#region GetList Functions
/// <summary>
/// Gets All rows from the DataSource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out. The number of rows that match this query.</param>
/// <remarks></remarks>
/// <returns>Returns a typed collection of SmartMassEmail.Entities.EmailMessageDetail objects.</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 SmartMassEmail.Entities.TList<EmailMessageDetail> GetAll(TransactionManager transactionManager, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_Get_List", _useStoredProcedure);
IDataReader reader = null;
//Create Collection
SmartMassEmail.Entities.TList<EmailMessageDetail> rows = new SmartMassEmail.Entities.TList<EmailMessageDetail>();
try
{
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
Fill(reader, rows, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
}
finally
{
if (reader != null)
reader.Close();
}
return rows;
}//end getall
#endregion
#region Paged Recordset
/// <summary>
/// Gets a page of rows from the DataSource.
/// </summary>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">Number of rows in the DataSource.</param>
/// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param>
/// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC);</param>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <remarks></remarks>
/// <returns>Returns a typed collection of SmartMassEmail.Entities.EmailMessageDetail objects.</returns>
public override SmartMassEmail.Entities.TList<EmailMessageDetail> GetPaged(TransactionManager transactionManager, string whereClause, string orderBy, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_GetPaged", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@WhereClause", DbType.String, whereClause);
database.AddInParameter(commandWrapper, "@OrderBy", DbType.String, orderBy);
database.AddInParameter(commandWrapper, "@PageIndex", DbType.Int32, start);
database.AddInParameter(commandWrapper, "@PageSize", DbType.Int32, pageLength);
IDataReader reader = null;
//Create Collection
SmartMassEmail.Entities.TList<EmailMessageDetail> rows = new SmartMassEmail.Entities.TList<EmailMessageDetail>();
try
{
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
Fill(reader, rows, 0, int.MaxValue);
count = rows.Count;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
}
catch(Exception)
{
throw;
}
finally
{
if (reader != null)
reader.Close();
}
return rows;
}
#endregion
#region Get By Foreign Key Functions
#region GetByEmailMessageID
/// <summary>
/// Gets rows from the datasource based on the FK_EmailMessageDetail_EmailMessage key.
/// FK_EmailMessageDetail_EmailMessage Description:
/// </summary>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="emailMessageID"></param>
/// <param name="count">out parameter to get total records for query</param>
/// <remarks></remarks>
/// <returns>Returns a typed collection of SmartMassEmail.Entities.EmailMessageDetail objects.</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 SmartMassEmail.Entities.TList<EmailMessageDetail> GetByEmailMessageID(TransactionManager transactionManager, System.Guid emailMessageID, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_GetByEmailMessageID", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@EmailMessageID", DbType.Guid, emailMessageID);
IDataReader reader = null;
SmartMassEmail.Entities.TList<EmailMessageDetail> rows = new SmartMassEmail.Entities.TList<EmailMessageDetail>();
try
{
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
//Create Collection
Fill(reader, rows, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
}
finally
{
if (reader != null)
reader.Close();
}
return rows;
}
#endregion
#endregion
#region Get By Index Functions
#region GetByID
/// <summary>
/// Gets rows from the datasource based on the PK_EmailMessageDetail index.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="id"></param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out parameter to get total records for query</param>
/// <returns>Returns an instance of the <see cref="SmartMassEmail.Entities.EmailMessageDetail"/> class.</returns>
/// <remarks></remarks>
/// <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 SmartMassEmail.Entities.EmailMessageDetail GetByID(TransactionManager transactionManager, System.Guid id, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_GetByID", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@ID", DbType.Guid, id);
IDataReader reader = null;
SmartMassEmail.Entities.TList<EmailMessageDetail> tmp = new SmartMassEmail.Entities.TList<EmailMessageDetail>();
try
{
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
//Create collection and fill
Fill(reader, tmp, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
}
finally
{
if (reader != null)
reader.Close();
}
if (tmp.Count == 1)
{
return tmp[0];
}
else if (tmp.Count == 0)
{
return null;
}
else
{
throw new DataException("Cannot find the unique instance of the class.");
}
//return rows;
}
#endregion
#endregion Get By Index Functions
#region Insert Functions
/// <summary>
/// Lets you efficiently bulk many entity to the database.
/// </summary>
/// <param name="transactionManager">The transaction manager.</param>
/// <param name="entities">The entities.</param>
/// <remarks>
/// After inserting into the datasource, the SmartMassEmail.Entities.EmailMessageDetail object will be updated
/// to refelect any changes made by the datasource. (ie: identity or computed columns)
/// </remarks>
public override void BulkInsert(TransactionManager transactionManager, TList<SmartMassEmail.Entities.EmailMessageDetail> entities)
{
//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
if (transactionManager != null && transactionManager.IsOpen)
{
System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
}
else
{
bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
}
bulkCopy.BulkCopyTimeout = 360;
bulkCopy.DestinationTableName = "EmailMessageDetail";
DataTable dataTable = new DataTable();
DataColumn col0 = dataTable.Columns.Add("ID", typeof(System.Guid));
col0.AllowDBNull = false;
DataColumn col1 = dataTable.Columns.Add("ChangeStamp", typeof(System.DateTime));
col1.AllowDBNull = false;
DataColumn col2 = dataTable.Columns.Add("IsBinary", typeof(System.Int32));
col2.AllowDBNull = false;
DataColumn col3 = dataTable.Columns.Add("Name", typeof(System.String));
col3.AllowDBNull = false;
DataColumn col4 = dataTable.Columns.Add("BinaryData", typeof(System.Byte[]));
col4.AllowDBNull = false;
DataColumn col5 = dataTable.Columns.Add("StringData", typeof(System.String));
col5.AllowDBNull = false;
DataColumn col6 = dataTable.Columns.Add("EmailMessageID", typeof(System.Guid));
col6.AllowDBNull = false;
bulkCopy.ColumnMappings.Add("ID", "ID");
bulkCopy.ColumnMappings.Add("ChangeStamp", "ChangeStamp");
bulkCopy.ColumnMappings.Add("IsBinary", "IsBinary");
bulkCopy.ColumnMappings.Add("Name", "Name");
bulkCopy.ColumnMappings.Add("BinaryData", "BinaryData");
bulkCopy.ColumnMappings.Add("StringData", "StringData");
bulkCopy.ColumnMappings.Add("EmailMessageID", "EmailMessageID");
foreach(SmartMassEmail.Entities.EmailMessageDetail entity in entities)
{
if (entity.EntityState != EntityState.Added)
continue;
DataRow row = dataTable.NewRow();
row["ID"] = entity.ID;
row["ChangeStamp"] = entity.ChangeStamp;
row["IsBinary"] = entity.IsBinary;
row["Name"] = entity.Name;
row["BinaryData"] = entity.BinaryData;
row["StringData"] = entity.StringData;
row["EmailMessageID"] = entity.EmailMessageID;
dataTable.Rows.Add(row);
}
// send the data to the server
bulkCopy.WriteToServer(dataTable);
// update back the state
foreach(SmartMassEmail.Entities.EmailMessageDetail entity in entities)
{
if (entity.EntityState != EntityState.Added)
continue;
entity.AcceptChanges();
}
}
/// <summary>
/// Inserts a SmartMassEmail.Entities.EmailMessageDetail object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">SmartMassEmail.Entities.EmailMessageDetail object to insert.</param>
/// <remarks>
/// After inserting into 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 Insert(TransactionManager transactionManager, SmartMassEmail.Entities.EmailMessageDetail entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.EmailMessageDetail_Insert", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@ID", DbType.Guid, entity.ID );
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);
}
entity.OriginalID = entity.ID;
entity.AcceptChanges();
return Convert.ToBoolean(results);
}
#endregion
#region Update Functions
/// <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);
}
#endregion
#region Custom Methods
#endregion
}//end class
} // end namespace