Castle Activerecord中的Not-found =“ignore”行为

时间:2010-09-30 16:17:54

标签: asp.net sql-server nhibernate castle-activerecord

使用Castle Activerecord时,是否可以在键映射上实现NHibernate的'not-found =“ignore”'行为?

我在ASP.Net Web应用程序中使用现有的遗留Castle Activerecord类来映射到旧的只读MSSQL数据库。我无法以任何方式改变数据库。

父Product表与Type表有关系,但Product表包含许多记录,其Type值包含0,而Type表上没有给出等效记录。

我被要求添加Product和Type类之间的映射,如果可能,需要忽略破坏的引用完整性的出现。 'not-found =“忽略”'方法将是我使用vanilla NHibernate的方式。

2 个答案:

答案 0 :(得分:1)

ActiveRecord关系属性有NotFoundBehavior property映射到NHibernate的not-found

Here's an example.

答案 1 :(得分:0)

作为一种解决方法,我在Product类中添加了一个GetProductType()方法来检索Type。

我仍然对使用Castle的可配置方式感兴趣:)