Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8299355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:07:20+00:00 2026-06-08T16:07:20+00:00

What if I new up some DataContexts, read some data, and then only wrap

  • 0

What if I new up some DataContexts, read some data, and then only wrap the SubmitChanges in a TransactionScope?

string conn1 = GetConn1();
string conn2 = GetConn2();
using (DataContext1 dc1 = new DataContext1(conn1))
{
  List<Customer> customers = ReadSomeData(dc1);
  ModifySomeCustomers(customers);  //performs local modification to Customer instances

  using (DataContext2 dc2 = new DataContext2(conn2))
  {
    List<Order> orders = ReadSomeData(dc2);
    ModifySomeOrders(orders); //performs local modification to Order instances

    using (TransactionScope scope = new TransactionScope())
    {
      dc1.SubmitChanges();
      dc2.SubmitChanges();
      scope.Complete();
    }
  }
}

The first SubmitChanges call is expected to fetch a connection from the pool and enlist that connection in the scope.
MS DTC is enabled – the second SubmitChanges call is expected to promote the transaction to “distributed”, fetch a connection from the pool and enlist that connection in the scope.

I’m concerned that ReadSomeData may have left the connection open, so SubmitChanges doesn’t fetch a connection from the pool, and therefore doesn’t enlist the connection in the scope.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:07:21+00:00Added an answer on June 8, 2026 at 4:07 pm

    SubmitChanges will participate in the TransactionScope.

    If SubmitChanges finds an ambient transaction it enlists to that transaction, otherwise it creates a transaction itself for the lifetime of the SubmitChanges method.

    There is an MSDN Article about the transaction handling in SubmitChanges.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to some of App Development and was wondering the following; How can
I just wrote some new utility methods within a non-page class for an existing
I am writing some new SQL queries and want to check the query plans
I've testing some new CLR 4.0 behavior in method inlining (cross-assembly inlining) and found
I've created some new fields for users who register in admin/config/people/profile since we are
Instead of throwing new Exception(Some message, maybeSomeCause) , which means that all callers of
I need to implement some new functions on an editor. I picked Emacs -
As you know HTML5 introduced some new html tag, like footer,header, ... What prevent
I ported some code from C to C# and I also added some new
I was just poking around into some new stuff in C++0x, when I hit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.