我试图连接到多个数据库中的城堡活动记录(使用NHibernate的。)我的配置文件看起来是这样的:连接到多个数据库中的Active Record
<configSections>
<section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<activerecord>
<config type="Navtrak.Business.Schemas.CommonSchemas.Models.NavtrakOperations.NavtrakOperationsDatabase`1, CommonSchemas">
<add key="hibernate.connection.connection_string" value="myconnstring" />
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
</config>
<config type="Navtrak.Business.Schemas.CommonSchemas.Models.Errors.ErrorsDatabase`1, CommonSchemas">
<add key="hibernate.connection.connection_string" value="Data Source=myconnstring" />
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
</config>
</activerecord>
然后,我有一个抽象基类似于这样的每个数据库:
public abstract class NavtrakOperationsDatabase<T> : ActiveRecordBase<T>
{
}
然后每个类都从此继承。然后我初始化活动记录是这样的:
ActiveRecordStarter.Initialize(typeof(SimpleModel).Assembly, ActiveRecordSectionHandler.Instance);
这给我的错误:
找不到在配置方言
如果我改变激活码这样的:
ActiveRecordStarter.Initialize(
ActiveRecordSectionHandler.Instance,
typeof(NavtrakOperationsDatabase<>),
typeof(ErrorsDatabase<>)
);
然后我得到以下错误:
您已访问未正确初始化的ActiveRecord类。有两种可能的解释:对ActiveRecordStarter.Initialize()的调用不包括Navtrak.Business.Schemas.CommonSchemas.Models.NavtrakOperations.Application类,或Navtrak.Business.Schemas.CommonSchemas.Models.NavtrakOperations.Application类没有用[ActiveRecord]属性修饰。
我明显不希望在Initialize函数中包含每一个类。
任何想法?
你使用的是哪个版本的activerecord? – 2011-02-01 22:09:40
@Mauricio Scheffer - 我使用.NET 4的最新dll(我认为),因为我在一周前下载了它们。 – Justin 2011-02-01 22:26:35