views:

86

answers:

1

Hi everyone...

There is a way to use Castle ActiveRecord Integration (Castle.Facilities.ActiveRecordIntegration.dll) with multiple databases?

I'm already aware of using NHibernate with multiple database and ActiveRecord as well. But applied to integration facility i don't found anything.

Any suggestions?

Tks!!

+1  A: 

It's pretty much the same as accessing multiple databases without the facility. You define a <config> element for each database (as detailed in the AR docs), e.g.:

<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>

You can also use DifferentDatabaseScope as an alternative.

Mauricio Scheffer

related questions