I'm using EPiServer Commerce 7.6 and want to create a transaction that spans changes to a cart/purchaseorder and an update to a custom table using SqlHelper.ExecuteReader.
I've tried using the TransactionScope from MediaChase.Provider.Data which works for the cart.AcceptChanges but not for the custom table, and when I use SqlContext.Current.BeginTransaction()/SqlContext.CurrentTransaction.Commit() (see below) it works for my custom table but not cart.AcceptChanges().
SqlContext.Current.BeginTransaction();
try
{
if (order.GetWMSeReceiptId() == -1)
{ // Update of custom table containing a sequence number
var receiptId = ConfigurationHelpers.ReceiptId(SqlContext.Current.Transaction);
order.SetWMSeReceiptId((int) receiptId);
var receiptNumber = IntegrationHelpers.GetReceiptStoreRunningNumber(order);
order.SetWMSeReceiptNumber(receiptNumber);
order.AcceptChanges();
}
_service.SendReceipt(order);
order.SetWebShopOrderStatus("WMSeReceiptSent");
order.AcceptChanges();
receiptsSent++;
SqlContext.Current.Transaction.Commit();
}
catch (Exception exception)
{
SqlContext.Current.Transaction.Rollback();
throw;
}
Hi,
I'm using EPiServer Commerce 7.6 and want to create a transaction that spans changes to a cart/purchaseorder and an update to a custom table using SqlHelper.ExecuteReader.
I've tried using the TransactionScope from MediaChase.Provider.Data which works for the cart.AcceptChanges but not for the custom table, and when I use SqlContext.Current.BeginTransaction()/SqlContext.CurrentTransaction.Commit() (see below) it works for my custom table but not cart.AcceptChanges().