NHibernate version: 1.0.2
Hello,
I have a problem. I have the following tables:
Code:
_____________________
|Bank |
|---------------------|
|id : Guid |
|bankname : wchar(200)|
|_____________________|
|
|
/|\
_____________________
|Constraint |
|---------------------|
|id : Guid |
|id_bank : Guid |
|note : wchar(200) |
|_____________________|
I mapped the tables like this:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="BankManager" assembly="BankManager">
<class name="Bank" table="Bank">
<id name="Id" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<column name="id" sql-type="Guid" not-null="true" />
<generator class="guid" />
</id>
<property name="BankName">
<column name="bankname" length="200" not-null="true"/>
</property>
<map name="Constraints" table="Constraint">
<key column="id_bank" />
<index column="id" type="Guid"/>
<one-to-many class="Constraint" />
</map>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="BankManager" assembly="BankManager">
<class name="Constraint" table="Constraint">
<id name="Id" column="id" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid" />
</id>
<property name="Name">
<column name="name" length="200" not-null="false"/>
</property>
<property name="Note">
<column name="note" length="200" not-null="false"/>
</property>
</class>
</hibernate-mapping>
Now I want to select the bank with the name "TestBank", therefor I use the HQL like this:
Code:
IQuery bankQuery = session.CreateQuery(
@"select b from Bank as b
where (b.bankname = :bankname)");
bankQuery.SetString("bankname", "TestBank");
The result is the right bank with a list of constraints. But now I'd like to filter the constraints so that I get a bank with a "smaller" list of Constraints. For example only the Constraints with a note like 'Hello Wo%' should selected into the list.
Ho can I do this?