This didn't really answer the problem, only pointing out details that I might have done differently. I'm sorry I haven't followed up this question, my attention has been required elsewhere.
Main Topics
Browse All TopicsI am having trouble with LINQ and transactions when two transactions share the same DataContext object.
In the simplified code below I will get an System.Data.SqlClient.SqlE
It is interesting to note that when I debug the second block with the DataContext object shared with the first block, dc.Users contain only already existing user rows; there is no trace of the user row I added in the first block of code.
Also, when I avoid DataContext and use a SqlCommand object to query the database within code block 2, there is no trace of the supposedly existing row. (It exists, of course, if I do the same query in the first code block.)
The code will work if the var dc = new WebPortalDataContext(); is created within each transaction, however in our web application we share the DataContext object for each request. I've read several discussions on why to do this, or not -- but hope not to get into this discussion now :)
The question becomes: Why doesn't the transaction appear to roll back?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: DaTribePosted on 2009-08-20 at 07:51:35ID: 25143251
There are several things you are doing and not doing which are unnecessary and necessary.
1. When using "USING" the dispose method is automatically called at the end of the block.
2. When using TransactionScope you need to use the trans.Complete method to commit the transaction
3. I do not see any delete row code therefore you will always get this row already inserted error.
Try deleting the row from the DB manually. Remove the trans.Dispose and try again and see if the transaction rolls back.