Remember database transaction lock once

Source: Internet
Author: User

Recently encountered a problem in the project, transaction lock.

Transactionoptions tos = new Transactionoptions ();

Tos. IsolationLevel = Isolationlevel.repeatableread; A row lock locks only the row of data for the current operation, and other data for the current table is not affected. (verified)

isolationlevel.serializable; Table lock the current operation will lock the entire table, only after the transaction commits, the data of the table can be manipulated (verified)

"SELECT * from tableName where id = 1 for update"; Use for update when querying, the current data row can still be updated, but when the thing is not committed, the other transaction re-operation of the table will lock the row, you need to wait for the transaction to be committed before it can be manipulated and committed (not verified)

Tos. Timeout = new TimeSpan (0, 2, 0);

using (TransactionScope ts = new TransactionScope (transactionscopeoption.required, TOS))
{
 
Business Processing
Initstockqty (item);
Ts.complete ();
}

Remember database transaction lock once

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.