在Castle Active Record中传递我自己的ConnectionString

时间:2010-02-12 17:33:07

标签: nhibernate castle-activerecord

如果使用Castle Active Record,我如何注入自己的ConnectionString?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

我从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);
}