views:

32

answers:

2

Is it possible to implement the 'not-found="ignore"' behaviour of NHibernate on a key mapping when using Castle Activerecord?

I am using existing legacy Castle Activerecord classes within an ASP.Net web application to map to a legacy, read only, MSSQL database. I cannot alter the database in any way.

The parent Product table has a relationship with a Type table, however the Product table contains numerous records with Type values containing a 0 which have not been given an equivalent record on the Type table.

I have been asked to add the mapping between the Product and Type class and need to ignore the occurrences of broken referential integrity if possible. The 'not-found="ignore"' method would be the way I would go about this using vanilla NHibernate.

A: 

As a workaround I have added a GetProductType() method to the Product class to retrieve the Type.

I am still interested for a configurable way to do this with Castle though :)

Kynth
+1  A: 

ActiveRecord relation attributes have a NotFoundBehavior property that maps to NHibernate's not-found

Here's an example.

Mauricio Scheffer
Perfect, thank you very much.
Kynth