0

I'm trying to use an NHibernate filter to filter on a parent class's property, but I keep getting an error that the multi-part identifier "Parent.Active" could not be bound. My filter-def is:

<filter-def name="useActive" />

My parent class has this in the mapping:

<property name="Active">
    <column name="ACTIVE" not-null="true" />
</property>
<bag name="Children" table="CHILDREN" inverse="true">
    <key>
        <column name="PARENT_ID_IN_CHILD" />
    </key>
    <one-to-many class="ChildType" />
</bag>

My child class has this in the mapping:

<many-to-one name="Parent" class="ParentTyle">
    <column name="PARENT_ID_IN_CHILD" />
</many-to-one>
<filter name="useActive" condition="Parent.Active = 1" />

How can I get NHibernate to check the parent column when filtering?

edit: I'm enabling the filter using mySession.EnableFilter("useActive");. I'm also using LINQ-to-NHibernate, but I don't think that should matter.

Becca Dee
  • 1,530
  • 1
  • 24
  • 51

1 Answers1

0

The error you're receiving came from SQL Server that can't find the column "Active" on the table "Parent". Keep in mind that when you're defining a filter the string that you put in the condition will simply be appended in the where condition of the select as is. If you want to filter for that field you must first identify the alias nHibernate use for your SQL query than put that alias instead of "Parent". it coube something like "mytable_0" or something like that.

mCasamento
  • 1,413
  • 1
  • 11
  • 21