0

Lets consider the following simplified mapping:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"  assembly="xxx" namespace="yyy">
  <class name="Customer" table="Customers">
    <id name="Id" column="customerID" type="Int64">
      <generator class="native"/>
    </id>

    <!-- LOOK AT THE WHERE BELOW .-->
    <map where="codeType='BO'" name="Conversions" table="CustomersCodes" >
      <key column="customerID"></key>
      <index   column="codeType" type="AnsiString"/>
      <element column="code" type="AnsiString"/>
    </map>

  </class>
</hibernate-mapping>

I would like to dinamycally specify the where ( that is sticked in the mapping in the sample ) in code, is it possible ?

As a viable alternative, is it possible to fetch just a key of the map with QueryOver or LinqToNH ? I did try with link to NH but it complain that the map does not contain an entity ( true, since it is a map of elements, that is perfectly valid in NH and useful to optimize the speed in many cases )

Gerard
  • 2,461
  • 2
  • 26
  • 34
Felice Pollano
  • 32,832
  • 9
  • 75
  • 115

1 Answers1

1

Perhaps NHibernate Filters could help you here Contextual data using NHibernate filters

Mark Perry
  • 1,705
  • 10
  • 12