Search code examples
c#.netvb.netnhibernatenhibernate-mapping

How can I override NHibernate's Class mapping Where clause?


I have an NHibernate mapping that looks like this:

<class name="Customer" table="Customer" where="Region=0">
    ...
</class>

I cannot change this mapping without serious impact on other areas of the application.

Is there a way I can query for Customers not in Region 0, avoiding NHibernate appending a (where Region=0) to all of the SQL queries?


Solution

  • Add an OR clause in the method where you need customers from all regions

    OR Region <> 0
    

    Which technically is equivalent to take customers from all regions.