Take a look at DifferentDatabaseScope.

Here's the testcase for reference:
https://svn.castleproject.org/svn/castle/trunk/ActiveRecord/Castle.ActiveRecord.Tests/DifferentDatabaseScopeTestCase.cs

On Aug 6, 10:43 pm, EricP <[email protected]> wrote:
> In my project we have some older modules written using straight
> ADO.NET and some newer modules that use Castle Active Record.  In
> several places where ADO.NET code and NHibernate code are used in the
> same TransactionScope - I started getting errors that MSDTC is not
> available.
>
> Here is the sample code that results in exception:
>
> ===========================
>
> using (var scope=System.Transactions.TransactionScope())
> {
>
>    using(var connection = new SqlConnection(connectionString))
>    {
>         cn.Open();
>
>         //Make some changes using ADO.NET
>         string insertQuery = @"insert into employee ....";
>         SqlCommand cmd = new SqlCommand(insertQuery, cn);
>         cmd.ExecuteNonQuery();
>
>         // Make some changes using AR session
>         using (new SessionScope())   //Need to pass cn in here somehow
>         {
>                 var Customer = new Customer(...);
>                 customer.Save();        //Get exception that "MSDTC on
> server '...' is unavailable."
>         }
>
>    }
>
>    scope.Complete();
>
> }
>
> ===================
>
> This occurs because ADO.NET code is using one connection, while
> ActiveRecord creates another one.
> If I used NHibernate directly I could probably call
> SessionFactory.OpenSession(cn); with my ADO.NET connection to get
> around MSDTC issue.
>
> How would I do the same for ActiveRecord?
>
> Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to