I am using NHibernate 2.1. I am trying to use a filter in a property formula, but am getting the following error:
filter-def for filter named 'SiteFilter' was never used to filter classes nor collections.
Here is my mapping file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataAccess" namespace="DataAccess.Catalog">
<class name="Model.Catalog.Category,Model" table="Catalog.Category">
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="Name" column="Name" type="string" length="50" not-null="true" />
<property name="ProductCount" formula="(SELECT COUNT(*) from Catalog.Product WHERE Product.CategoryID = ID)" lazy="true" />
<property name="SiteProductCount" formula="(SELECT COUNT(*) from Catalog.Product WHERE Product.CategoryID = :SiteFilter.SiteID)" lazy="true" />
<many-to-one name="Image"
column="ImageID"
not-null="true"
class="Model.Catalog.Image,Model"
cascade="save-update" />
<bag name="Products" table="Catalog.Product" generic="true" inverse="true">
<key column="CategoryID" />
<one-to-many class="Model.Catalog.Product,Model"/>
</bag>
</class>
<filter-def name="SiteFilter">
<filter-param name="SiteID" type="Int32" />
</filter-def>
</hibernate-mapping>
What am I doing wrong? Thanks for any help!