本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabase.AddParameter方法的具体用法?C# SqlDatabase.AddParameter怎么用?C# SqlDatabase.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase
的用法示例。
在下文中一共展示了SqlDatabase.AddParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateStatus
/// <summary>
/// This method wraps the '_Appointment_UpdateStatus' stored procedure.
/// </summary>
/// <param name="oldId"> A <c>System.String</c> instance.</param>
/// <param name="patientCode"> A <c>System.String</c> instance.</param>
/// <param name="statusId"> A <c>System.String</c> instance.</param>
/// <param name="updateUser"> A <c>System.String</c> instance.</param>
/// <param name="result"> A <c>System.Int32?</c> instance.</param>
/// <param name="id"> A <c>System.String</c> instance.</param>
/// <param name="note"> A <c>System.String</c> instance.</param>
/// <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>
/// <remark>This method is generated from a stored procedure.</remark>
public override void UpdateStatus(TransactionManager transactionManager, int start, int pageLength , System.String oldId, System.String patientCode, System.String statusId, System.String updateUser, ref System.Int32? result, ref System.String id, ref System.String note)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo._Appointment_UpdateStatus", true);
database.AddInParameter(commandWrapper, "@OldId", DbType.String, oldId );
database.AddInParameter(commandWrapper, "@PatientCode", DbType.StringFixedLength, patientCode );
database.AddInParameter(commandWrapper, "@StatusId", DbType.String, statusId );
database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, updateUser );
database.AddParameter(commandWrapper, "@Result", DbType.Int32, 4, ParameterDirection.InputOutput, true, 10, 0, string.Empty, DataRowVersion.Current, result);
database.AddParameter(commandWrapper, "@Id", DbType.String, 20, ParameterDirection.InputOutput, true, 0, 0, string.Empty, DataRowVersion.Current, id);
database.AddParameter(commandWrapper, "@Note", DbType.String, 500, ParameterDirection.InputOutput, true, 0, 0, string.Empty, DataRowVersion.Current, note);
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "UpdateStatus", (IEntity)null));
if (transactionManager != null)
{
Utility.ExecuteNonQuery(transactionManager, commandWrapper );
}
else
{
Utility.ExecuteNonQuery(database, commandWrapper);
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "UpdateStatus", (IEntity)null));
result = Utility.GetParameterValue<System.Int32?>(commandWrapper.Parameters["@Result"]);
id = Utility.GetParameterValue<System.String>(commandWrapper.Parameters["@Id"]);
note = Utility.GetParameterValue<System.String>(commandWrapper.Parameters["@Note"]);
return;
}
示例2: Update
/// <summary>
/// Update an existing row in the datasource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">Nettiers.AdventureWorks.Entities.SalesOrderDetail object to update.</param>
/// <remarks>
/// After updating the datasource, the Nettiers.AdventureWorks.Entities.SalesOrderDetail 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, Nettiers.AdventureWorks.Entities.SalesOrderDetail entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Sales.usp_adwTiers_SalesOrderDetail_Update", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@SalesOrderId", DbType.Int32, entity.SalesOrderId );
database.AddInParameter(commandWrapper, "@OriginalSalesOrderId", DbType.Int32, entity.OriginalSalesOrderId);
database.AddInParameter(commandWrapper, "@SalesOrderDetailId", DbType.Int32, entity.SalesOrderDetailId );
database.AddInParameter(commandWrapper, "@CarrierTrackingNumber", DbType.String, entity.CarrierTrackingNumber );
database.AddInParameter(commandWrapper, "@OrderQty", DbType.Int16, entity.OrderQty );
database.AddInParameter(commandWrapper, "@ProductId", DbType.Int32, entity.ProductId );
database.AddInParameter(commandWrapper, "@SpecialOfferId", DbType.Int32, entity.SpecialOfferId );
database.AddInParameter(commandWrapper, "@UnitPrice", DbType.Currency, entity.UnitPrice );
database.AddInParameter(commandWrapper, "@UnitPriceDiscount", DbType.Currency, entity.UnitPriceDiscount );
database.AddParameter(commandWrapper, "@LineTotal", SqlDbType.Decimal, 17, ParameterDirection.Output, true, 38, 6, null, DataRowVersion.Default, null);
database.AddInParameter(commandWrapper, "@Rowguid", DbType.Guid, entity.Rowguid );
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate );
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);
entity.OriginalSalesOrderId = entity.SalesOrderId;
object _lineTotal = database.GetParameterValue(commandWrapper, "@LineTotal");
entity.LineTotal = (System.Decimal)_lineTotal;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));
return Convert.ToBoolean(results);
}