Search code examples
c#castle-activerecord

Can I attach criterias for a HasMany entity?


I have an Incident class that uses the HasMany attribute to a Location class. All works using the static Find methods. But I need to add a where clause to the Location table. I can use the Where attribute but I don't always want that clause when fetching results.

Is there any way to maybe use DetachedCriteria or something similar while querying for Incident to filter the Location table? I could use hql but it seems that I have to create my joins manually which seems redundant if I use the HasMany attribute.


Solution

  • The [HasMany] attribute has a Where property that filters the relationship.

    Another way to do semi-global filtering is with session filters.