Home

Castle Stronghold

Accessing more than one database

You can use more than one database with ActiveRecord. In order to do so you must create base classes that define, based on the hierarchy, which database is being used. Those are called Root types. If you use just one database, the root type is ActiveRecordBase.

Adding a different database

Let's analyze the steps involved in getting ActiveRecord to work with more than one database.

First: Create your root type

You must create an abstract class that extends ActiveRecordBase. This class can be empty. All ActiveRecord types bound to the second database must use it as the base class.


using Castle.ActiveRecord

public abstract class LogisticDatabase : ActiveRecordBase
{
}

Second: configure the second database

On the existing configuration, you must use add another config set bound to the abstract class you have just created. For more information on it, see Xml Configuration Reference.

Google
Search WWW Search castleproject.org