How can I wrap a transaction around Membership.CreateUser?

I am using asp.net SqlMembershipProvider and LinqToSql in a hobby / learning application. I have some user properties that I store in LinqtoSql, so my stream is: Membership.CreateUser -> MyClass.AddUserDetails. I would like to wrap all this in a transaction, so if the myclass bit fails, I can drop the membership bit. Any suggestions on how to do this?

+3
source share
3 answers

Providers clearly do not support transactions, I asked this function a while ago:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102268

, TransactionScope, , , MSDTC.

+3

( ):

  • .
  • ( SqlProvider)
  • DTC.
  • .
  • DTC .
  • .
  • .
  • 4 , DTC.
  • , .
  • .

...

+4

You can set the transaction property DataContext so that it participates in the transaction that you already have.

0
source

Source: https://habr.com/ru/post/1697860/


All Articles