Search code examples
nhibernatecastle-activerecord

Passing my own ConnectionString in Castle Active Record


How can I inject my own ConnectionString if using Castle Active Record?


Solution

  • I have got the answer for this from http://www.darkside.co.za/archive/2008/01/21/castle-activerecord-connecting-to-multiple-databases.aspx

    IDbConnection connection = new SqlConnection("Data Source=.;Initial Catalog=TestB;Integrated Security=SSPI");
    connection.Open();
    using (new DifferentDatabaseScope(connection))
    {
        TestTableDatabaseA test3 = TestTableDatabaseA.Find(1);
        Console.WriteLine(test3.Title);
    }