具有多个数据库的Castle ActiveRecord Integration

时间:2010-08-09 19:35:09

标签: castle-windsor castle-activerecord

有一种方法可以将Castle ActiveRecord Integration(Castle.Facilities.ActiveRecordIntegration.dll)与多个数据库一起使用吗?

我已经知道将NHibernate与多个数据库和ActiveRecord一起使用。但是应用于集成设施我没有找到任何东西。

有什么建议吗?

韩国社交协会!!

1 个答案:

答案 0 :(得分:1)

与没有设施访问多个数据库几乎相同。您为每个数据库定义<config>元素(如detailed in the AR docs),例如:

<facility id="arfacility">
    <assemblies>
        <item>MyAssembly</item>
    </assemblies>
    <config>
        <add key="connection.driver_class" value="NHibernate.Driver.SQLite20Driver" />
        <add key="dialect"                 value="NHibernate.Dialect.SQLiteDialect" />
        <add key="connection.provider"     value="Castle.ActiveRecord.Testing.InMemoryConnectionProvider,Castle.ActiveRecord" />
        <add key="connection.connection_string" value="Data Source=:memory:;Version=3;New=True" />
        <add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
    </config>
    <config type="My.Secondary.Database.BaseClass, MyAssembly">
        <add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
        <add key="dialect"                 value="NHibernate.Dialect.MsSql2000Dialect" />
        <add key="connection.provider"     value="NHibernate.Connection.DriverConnectionProvider" />
        <add key="connection.connection_string" value="Data Source=.;Initial Catalog=test;Integrated Security=SSPI" />
        <add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
    </config>
</facility>

您也可以使用DifferentDatabaseScope作为替代方案。