Change uncertainty to confirmation ~ When is transactionscope upgraded to a distributed transaction ~ Finale

Source: Internet
Author: User

Back to directory

I wrote three articles about this.ArticleThe series are all centered around a topic, that is, when. NET will upgrade transactionscope to a distributed transaction. Today I borrowed the threadstatic feature to prove this knowledge point. The following is a summary:

Transactionscope article:

26th timesChange uncertainty to confirmation ~ When Will transactionscope be upgraded to a distributed transaction?

27th timesChange uncertainty to confirmation ~ When is transactionscope upgraded to a distributed transaction ~ Continued

28th timesChange uncertainty to confirmation ~ When is transactionscope upgraded to a distributed transaction ~ Continue (avoid unnecessary MSDTC)

Threadstatic feature article:

The foundation is the top priority ~ Threadstatic static field uniqueness in each thread

 

Summary:

As long as the data context is one, no distributed transactions will be generated

As long as the data context is one, multiple submitchanges will be merged and submitted at a time.

First, this is a datacontext graph with the threadstatic feature. I have disabled the MSDTC Service.

The following figure shows how to use a normal data context of an instance. It generates multiple data contexts and promotes transactionscope to a distributed transaction. Therefore, the exceptions shown in the following figure are thrown, haha!

The following is a method call: common instance Context

Threadstatic data context

The following is the transaction'sProgramIt has multiple operations, and each operation has its own submitchanges ()

The SQL statement it generates uses an SQL connection pool, and the performance is already optimal!

Back to directory

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.