Search code examples
asp.netsql-servernhibernatecastle-activerecord

Not-found="ignore" behaviour in Castle Activerecord


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.


Solution

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

    Here's an example.