Introduction affairs functions

开发工具与关键技术:vs2015  MVC
作者:陈星宇
撰写时间:2019.4.20

When we have more than a one-time New Laws deleted, there will be a problem, in front of New Laws to delete a complete failure to modify the back, while the front has been done, in order to deal with this problem we can use the transaction, the current face the operation is complete, once behind the operation fails, it will withdraw the new front delete modify completed.
We simply use to talk about a transaction
to use transactional matters, we must first reference
Here Insert Picture Description
we have to find in the framework of the referenced assemblies in System.Transactuions, and its check mark, then our business would quote a success.
And we can directly use the transaction in the project, using the way so
Here Insert Picture Description
we using the new a TransactionScope this transaction has succeeded
we can make changes in it
Here Insert Picture Description
if this modify the operation was successful then he will continue to go on
we'll be a new
Here Insert Picture Description
the new If successful, that code will continue execution
let us a delete operation
Here Insert Picture Description
if the delete operation fails, then the transaction will trigger function
before revision operation will withdraw back, the changes will revert to the pre-modified content
and the new operation will be canceled, but it has been added to the database, go back and undo generated when the ID
already exists but this data was revoked back, returned to its original state
after the operation is complete we need to commit the transaction, the transaction the completion of the operation truly
Here Insert Picture Description
is easy to operate and analyze the transactions above.

Guess you like

Origin blog.csdn.net/tianxiu11/article/details/89577968