John_
John_

Reputation: 2971

How do you filter one to many relationships with fluent-NHibernate?

I have a set of entities where they could possibly be set as deleted using an "IsDeleted" flag in the database.

This is fine for the normal set of entities, however when I have a parent with many child entities that may have this flag I would like NHibernate to be able to automatically handle selecting the child entities that have "IsDeleted" set to false.

Is there anyway to do this with fluent-NHibernate? Or the XML mappings that I could add view fluent.

Thanks

Upvotes: 1

Views: 1377

Answers (1)

James Gregory
James Gregory

Reputation: 14223

This is not something that can be done in the mappings, Fluent NHibernate or standard XML. What you need to do is register a DeleteEvent listener. There's a post on the NHibernate FAQ on Soft Deletes that's very good.

Upvotes: 1

Related Questions