本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase.AddOutParameter方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabase.AddOutParameter方法的具体用法?C# SqlDatabase.AddOutParameter怎么用?C# SqlDatabase.AddOutParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase
的用法示例。
在下文中一共展示了SqlDatabase.AddOutParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addNewUser
public int addNewUser(string firstname, string lastname, string companyname, string email, string password, string countryid, string stateid, string mobile, int type, string verify)
{
int status = 0;
try
{
Guid guid = Guid.NewGuid();
Database objDB = new SqlDatabase(connectionStr);
DbCommand objAdd = new SqlCommand();
objAdd.CommandType = CommandType.StoredProcedure;
objAdd.CommandText = "InsertUser";
objDB.AddInParameter(objAdd, "@FName", DbType.String, firstname);
objDB.AddInParameter(objAdd, "@LName", DbType.String, lastname);
objDB.AddInParameter(objAdd, "@Companyname", DbType.String, companyname);
objDB.AddInParameter(objAdd, "@Email", DbType.String, email);
objDB.AddInParameter(objAdd, "@Password", DbType.String, password);
objDB.AddInParameter(objAdd, "@Countryid", DbType.Int32, countryid);
objDB.AddInParameter(objAdd, "@Stateid", DbType.Int32, stateid);
objDB.AddInParameter(objAdd, "@Mobile", DbType.String, mobile);
objDB.AddInParameter(objAdd, "@Type", DbType.Int32, type);
objDB.AddInParameter(objAdd, "@Verify", DbType.String, verify);
objDB.AddOutParameter(objAdd, "@Stat", DbType.Int16, 16);
objDB.ExecuteNonQuery(objAdd);
status = Convert.ToInt16(objDB.GetParameterValue(objAdd, "@Stat"));
return status;
}
catch (Exception ex)
{
objErr.GeneralExceptionHandling(ex, "Website - User Registration", "addNewUser", "GENERAL EXCEPTION");
return status;
}
}
示例2: addNewProductPost
public int addNewProductPost(string userid, int l1id, int l2id, int l3id, string productname, string keywords, string description, decimal quantity, decimal price, string image1,
string image2, string image3, string image4)
{
int status = 0;
try
{
Guid guid = new Guid(userid);
Database objDB = new SqlDatabase(connectionStr);
DbCommand objAdd = new SqlCommand();
objAdd.CommandType = CommandType.StoredProcedure;
objAdd.CommandText = "InsertProductPost";
objDB.AddInParameter(objAdd, "@USERID", DbType.Guid, guid);
objDB.AddInParameter(objAdd, "@L1ID", DbType.Int32, l1id);
objDB.AddInParameter(objAdd, "@L2ID", DbType.Int32, l2id);
objDB.AddInParameter(objAdd, "@L3ID", DbType.Int32, l3id);
objDB.AddInParameter(objAdd, "@PRODUCTNAME", DbType.String, productname);
objDB.AddInParameter(objAdd, "@DESCRIPTION", DbType.String, description);
objDB.AddInParameter(objAdd, "@QUANTITY", DbType.Decimal, quantity);
objDB.AddInParameter(objAdd, "@PRICE", DbType.Decimal, price);
objDB.AddInParameter(objAdd, "@KEYWORDS", DbType.String, keywords);
objDB.AddInParameter(objAdd, "@IMAGE1", DbType.String, image1);
objDB.AddInParameter(objAdd, "@IMAGE2", DbType.String, image2);
objDB.AddInParameter(objAdd, "@IMAGE3", DbType.String, image3);
objDB.AddInParameter(objAdd, "@IMAGE4", DbType.String, image4);
objDB.AddOutParameter(objAdd, "@Stat", DbType.Int16, 16);
objDB.ExecuteNonQuery(objAdd);
status = Convert.ToInt16(objDB.GetParameterValue(objAdd, "@Stat"));
}
catch (Exception ex)
{
objErr.GeneralExceptionHandling(ex, "Website - Post Product", "addNewProductPost", "GENERAL EXCEPTION");
}
return status;
}
示例3: addInquiry
public int addInquiry(string name, string email, string subject, string message)
{
int status = 0;
try
{
Database objDB = new SqlDatabase(connectionStr);
DbCommand objAdd = new SqlCommand();
objAdd.CommandType = CommandType.StoredProcedure;
objAdd.CommandText = "InsertInquiry";
objDB.AddInParameter(objAdd, "@Name", DbType.String, name);
objDB.AddInParameter(objAdd, "@Email", DbType.String, email);
objDB.AddInParameter(objAdd, "@Subject", DbType.String, subject);
objDB.AddInParameter(objAdd, "@Message", DbType.String, message);
objDB.AddOutParameter(objAdd, "@Stat", DbType.Int16, 16);
objDB.ExecuteNonQuery(objAdd);
status = Convert.ToInt16(objDB.GetParameterValue(objAdd, "@Stat"));
return status;
}
catch (Exception ex)
{
objCommom.LogFile("Contact.aspx", "addInquiry", ex);
return status;
}
}
示例4: UpdateMailer
public int UpdateMailer(int Id)
{
int status = 0;
try
{
Database objDB = new SqlDatabase(connectionStr);
DbCommand objAdd = new SqlCommand();
objAdd.CommandType = CommandType.StoredProcedure;
objAdd.CommandText = "UpdateClientbyId";
objDB.AddInParameter(objAdd, "@Id", DbType.Int32, Id);
objDB.AddOutParameter(objAdd, "@Status", DbType.Int16, 16);
objDB.ExecuteNonQuery(objAdd);
status = Convert.ToInt16(objDB.GetParameterValue(objAdd, "@Status"));
return status;
}
catch (Exception ex)
{
throw ex;
return status;
}
}
示例5: addSentMail
public int addSentMail(string strType, string strActive, string strEmailID)
{
try
{
int status;
Database objDB = new SqlDatabase(connectionStr);
DbCommand objAdd = new SqlCommand();
objAdd.CommandType = CommandType.StoredProcedure;
objAdd.CommandText = "PS_add_SentMailLog";
objDB.AddInParameter(objAdd, "@Type", DbType.String, strType);
objDB.AddInParameter(objAdd, "@Active", DbType.String, strActive);
objDB.AddInParameter(objAdd, "@EmailID", DbType.String, strEmailID);
objDB.AddOutParameter(objAdd, "@Status", DbType.Int16, 16);
objDB.ExecuteNonQuery(objAdd);
status = Convert.ToInt16(objDB.GetParameterValue(objAdd, "@Status"));
return status;
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
throw ex;
}
}
示例6: Insert
/// <summary>
/// Inserts a Nettiers.AdventureWorks.Entities.TimestampPk object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.TimestampPk object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the Nettiers.AdventureWorks.Entities.TimestampPk 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, Nettiers.AdventureWorks.Entities.TimestampPk entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Test.usp_adwTiers_TimestampPK_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@TimestampPk", DbType.Binary, 8);
database.AddInParameter(commandWrapper, "@SomeText", DbType.AnsiString, entity.SomeText );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _timestampPk = database.GetParameterValue(commandWrapper, "@TimestampPk");
entity.TimestampPk = (System.Byte[])_timestampPk;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例7: Update
/// <summary>
/// Update an existing row in the datasource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.TimestampPk object to update.</param>
/// <remarks>
/// After updating the datasource, the Nettiers.AdventureWorks.Entities.TimestampPk 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>
/// <exception cref="DBConcurrencyException">The record has been modified by an other user. Please reload the instance before updating.</exception>
public override bool Update(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.TimestampPk entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Test.usp_adwTiers_TimestampPK_Update", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@TimestampPk", DbType.Binary, entity.TimestampPk );
database.AddInParameter(commandWrapper, "@SomeText", DbType.AnsiString, entity.SomeText );
database.AddOutParameter(commandWrapper, "@ReturnedTimestampPk", DbType.Binary, 8);
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));
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);
if (results == 0)
{
throw new DBConcurrencyException("Concurrency exception");
}
entity.TimestampPk = (System.Byte[])database.GetParameterValue(commandWrapper, "@ReturnedTimestampPk");
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));
return Convert.ToBoolean(results);
}
示例8: Insert
/// <summary>
/// Inserts a HearbalKartDB.Entities.States object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">HearbalKartDB.Entities.States object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the HearbalKartDB.Entities.States 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, HearbalKartDB.Entities.States entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@Id", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@CountryId", DbType.Int32, (entity.CountryId.HasValue ? (object) entity.CountryId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@Name", DbType.String, entity.Name );
database.AddInParameter(commandWrapper, "@Pin", DbType.Int64, (entity.Pin.HasValue ? (object) entity.Pin : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@IsActive", DbType.Boolean, (entity.IsActive.HasValue ? (object) entity.IsActive : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@CreatedDate", DbType.DateTime, (entity.CreatedDate.HasValue ? (object) entity.CreatedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, (entity.ModifiedDate.HasValue ? (object) entity.ModifiedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@DeletedDate", DbType.DateTime, (entity.DeletedDate.HasValue ? (object) entity.DeletedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@PinCode", DbType.String, entity.PinCode );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _id = database.GetParameterValue(commandWrapper, "@Id");
entity.Id = (System.Int32)_id;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例9: Insert
/// <summary>
/// Inserts a Northwind.Entities.Employees object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Northwind.Entities.Employees object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the Northwind.Entities.Employees 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, Northwind.Entities.Employees entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.sp_nt_Employees_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@EmployeeId", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
database.AddInParameter(commandWrapper, "@TitleOfCourtesy", DbType.String, entity.TitleOfCourtesy );
database.AddInParameter(commandWrapper, "@BirthDate", DbType.DateTime, (entity.BirthDate.HasValue ? (object) entity.BirthDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@HireDate", DbType.DateTime, (entity.HireDate.HasValue ? (object) entity.HireDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@Address", DbType.String, entity.Address );
database.AddInParameter(commandWrapper, "@City", DbType.String, entity.City );
database.AddInParameter(commandWrapper, "@Region", DbType.String, entity.Region );
database.AddInParameter(commandWrapper, "@PostalCode", DbType.String, entity.PostalCode );
database.AddInParameter(commandWrapper, "@Country", DbType.String, entity.Country );
database.AddInParameter(commandWrapper, "@HomePhone", DbType.String, entity.HomePhone );
database.AddInParameter(commandWrapper, "@Extension", DbType.String, entity.Extension );
database.AddInParameter(commandWrapper, "@Photo", DbType.Binary, entity.Photo );
database.AddInParameter(commandWrapper, "@Notes", DbType.String, entity.Notes );
database.AddInParameter(commandWrapper, "@ReportsTo", DbType.Int32, (entity.ReportsTo.HasValue ? (object) entity.ReportsTo : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@PhotoPath", DbType.String, entity.PhotoPath );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _employeeId = database.GetParameterValue(commandWrapper, "@EmployeeId");
entity.EmployeeId = (System.Int32)_employeeId;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例10: Insert
/// <summary>
/// Inserts a Nettiers.AdventureWorks.Entities.StoreContact object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.StoreContact object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the Nettiers.AdventureWorks.Entities.StoreContact 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, Nettiers.AdventureWorks.Entities.StoreContact entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Sales.usp_adwTiers_StoreContact_Insert", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@CustomerId", DbType.Int32, entity.CustomerId );
database.AddInParameter(commandWrapper, "@ContactId", DbType.Int32, entity.ContactId );
database.AddInParameter(commandWrapper, "@ContactTypeId", DbType.Int32, entity.ContactTypeId );
database.AddOutParameter(commandWrapper, "@Rowguid", DbType.Guid, 16);
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _rowguid = database.GetParameterValue(commandWrapper, "@Rowguid");
entity.Rowguid = (System.Guid)_rowguid;
entity.OriginalCustomerId = entity.CustomerId;
entity.OriginalContactId = entity.ContactId;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例11: InsertContentMaster
public int InsertContentMaster(string strName, string strContent, Boolean Active)
{
int status = 0;
try
{
Database objDB = new SqlDatabase(connectionStr);
DbCommand objAdd = new SqlCommand();
objAdd.CommandType = CommandType.StoredProcedure;
objAdd.CommandText = "InsertContent";
objDB.AddInParameter(objAdd, "@Title", DbType.String, strName);
objDB.AddInParameter(objAdd, "@Content", DbType.String, strContent);
objDB.AddInParameter(objAdd, "@Status", DbType.Boolean, Active);
objDB.AddOutParameter(objAdd, "@Stat", DbType.Int16, 16);
objDB.ExecuteNonQuery(objAdd);
status = Convert.ToInt16(objDB.GetParameterValue(objAdd, "@Stat"));
return status;
}
catch (Exception ex)
{
objErr.GeneralExceptionHandling(ex, "Admin - Add New State", "InsertContentMaster", "GENERAL EXCEPTION");
return status;
}
}
示例12: Insert
/// <summary>
/// Inserts a Northwind.Entities.Categories object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Northwind.Entities.Categories object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the Northwind.Entities.Categories 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, Northwind.Entities.Categories entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.sp_nt_Categories_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@CategoryId", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@CategoryName", DbType.String, entity.CategoryName );
database.AddInParameter(commandWrapper, "@Description", DbType.String, entity.Description );
database.AddInParameter(commandWrapper, "@Picture", DbType.Binary, entity.Picture );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _categoryId = database.GetParameterValue(commandWrapper, "@CategoryId");
entity.CategoryId = (System.Int32)_categoryId;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例13: Insert
/// <summary>
/// Inserts a School.Entities.Students object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">School.Entities.Students object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the School.Entities.Students 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, School.Entities.Students entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Students_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@Id", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@Name", DbType.String, entity.Name );
database.AddInParameter(commandWrapper, "@Address", DbType.String, entity.Address );
database.AddInParameter(commandWrapper, "@ClassId", DbType.Int32, entity.ClassId );
database.AddInParameter(commandWrapper, "@Birthdate", DbType.Date, entity.Birthdate );
database.AddInParameter(commandWrapper, "@Gender", DbType.String, entity.Gender );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _id = database.GetParameterValue(commandWrapper, "@Id");
entity.Id = (System.Int32)_id;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例14: Insert
/// <summary>
/// Inserts a Nettiers.AdventureWorks.Entities.SalesPerson object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.SalesPerson object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the Nettiers.AdventureWorks.Entities.SalesPerson 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, Nettiers.AdventureWorks.Entities.SalesPerson entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Sales.usp_adwTiers_SalesPerson_Insert", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@SalesPersonId", DbType.Int32, entity.SalesPersonId );
database.AddInParameter(commandWrapper, "@TerritoryId", DbType.Int32, (entity.TerritoryId.HasValue ? (object) entity.TerritoryId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@SalesQuota", DbType.Currency, (entity.SalesQuota.HasValue ? (object) entity.SalesQuota : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@Bonus", DbType.Currency, entity.Bonus );
database.AddInParameter(commandWrapper, "@CommissionPct", DbType.Currency, entity.CommissionPct );
database.AddInParameter(commandWrapper, "@SalesYtd", DbType.Currency, entity.SalesYtd );
database.AddInParameter(commandWrapper, "@SalesLastYear", DbType.Currency, entity.SalesLastYear );
database.AddOutParameter(commandWrapper, "@Rowguid", DbType.Guid, 16);
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _rowguid = database.GetParameterValue(commandWrapper, "@Rowguid");
entity.Rowguid = (System.Guid)_rowguid;
entity.OriginalSalesPersonId = entity.SalesPersonId;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
示例15: Insert
/// <summary>
/// Inserts a AppointmentSystem.Entities.GroupRole object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">AppointmentSystem.Entities.GroupRole object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the AppointmentSystem.Entities.GroupRole 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, AppointmentSystem.Entities.GroupRole entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.GroupRole_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@Id", DbType.Int64, 8);
database.AddInParameter(commandWrapper, "@GroupId", DbType.String, entity.GroupId );
database.AddInParameter(commandWrapper, "@RoleId", DbType.Int32, (entity.RoleId.HasValue ? (object) entity.RoleId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _id = database.GetParameterValue(commandWrapper, "@Id");
entity.Id = (System.Int64)_id;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}