Transaction issues #1773
Replies: 1 comment
-
That will not work. Code running in the logical client-side (like you show) is not running in the app server - logical or physical. So you can't start a transaction on the client and have it flow to the server - ADO.NET doesn't support that concept. If you have multiple operations that need to run as part of a transaction, you should consider creating a unit of work class that encapsulates those steps, then you can invoke the unit of work as a single step. There are examples of this in the Using CSLA 4 book. Normally these are a command object, but sometimes they are implemented using This is the sort of thing you need: [Serializable]
public class BillDateUpdater : CommandBase<BillDateUpdater>
{
[Execute]
[Transactional(TransactionalTypes.TransactionScope)]
private void Execute()
{
InOutStockBillEdit InOutStockBillEdit = DataPortal.Create<InOutStockBillEdit>();
TransferBillEdit TransferBillEdit = DataPortal.Create<TransferBillEdit>();
InOutStockBillEdit.BillDate = DateTime.Now;
TransferBillEdit.BillDate = DateTime.Now;
InOutStockBillEdit = InOutStockBillEdit.Save();
TransferBillEdit = TransferBillEdit.Save();
}
} |
Beta Was this translation helpful? Give feedback.
-
Can I use it this way,Will the transaction be sent to the server?
Beta Was this translation helpful? Give feedback.
All reactions