Answer the question
In order to leave comments, you need to log in
How to implement a transaction script?
Good afternoon. An application for sales management is under development.
At the moment I have the following architecture:
DomainModel - objects for receiving data from the database (Receipts, Operations, Goods, Warehouses)
DAL - gateways to the database (IChequeGateway, IOperationGateway, ISellerGateway and the like for receiving data). These gateways use IDatabaseGateway - a wrapper over Firebird.
BLL - commands (CreateCheque, GetAllCheque, GetAllSellers, GetAllCustoms and the like) The
question is the following: it is necessary to execute the CreateCheque command within one database transaction - create a check, add its products, add goods write-off to operations, write to the log.
Obviously, in this case, you can either refer to different gateways - but then you need a dependence on the database transaction (which violates the abstraction of the gateway from a specific data source)
Or make all calls to different tables in the class that implements IChequeGateway - but then we work not only with the check table .
The database is accessed inside gateways via IDatabaseGateway (wrapper class over FirebirdClient).
Perhaps a little chaotically described, but so far as I can.
Please tell me a more or less correct way out of this situation. I am implementing such a multi-layer architecture with a database for the first time (C #)
Answer the question
In order to leave comments, you need to log in
Have you looked at the TransactionScope class? https://msdn.microsoft.com/en-us/library/system.tr... (v=vs.110).aspx
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question