Reputation: 7710
I'm using the asp.net SqlMembershipProvider and LinqToSql in a hobby/learning application. I have some user properties that I'm keeping in LinqtoSql, so my flow is: Membership.CreateUser -> MyClass.AddUserDetails. I'd like to wrap the whole thing in a transaction, so if the myclass bit fails I can roll back the membership bit. Any suggestions on how to do so?
Upvotes: 3
Views: 1764
Reputation: 124814
The providers don't explicitly support transactions, I asked for this feature some time ago:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102268
I think if you use the TransactionScope class it should work, though you will have the overhead of an MSDTC-coordinated transaction.
Upvotes: 3
Reputation: 31183
My real life experience (happened more than once):
I don't really like membership anymore...
Upvotes: 4
Reputation: 6675
You can set the Transaction property of the DataContext to make it participate in a transaction you already have.
Upvotes: 0