I have a class Person which could have several type of Identification.
Hence, I use Dictionary with a string as a key and another class,
Identification, as a value.
public class Person
{
...
public virtual IDictionary<string, Identification> Ids
{ get; set; }
...
}
public class Identification
{
public virtual string Value { get; set; }
}
Here is the mapping I got from Fluent NHibernate using AsMap() (with
some modification).
<class name="Person, Model, , Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
...
<map cascade="all-delete-orphan" name="Ids">
<key>
<column name="Person_id" />
</key>
<index type="System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="id_type" />
</index>
<one-to-many class="Identification, Model, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" />
</map>
...
</class>
<class name="Identification, Model, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" table="IDENTIFICATION">
<key>
<column name="Info_id" />
</key>
<property name="Value" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Value" not-null="true" />
</property>
</class>
Let's say if I would like to get a person who has "SSN",
Identification equal to some value. Could I do that in one HQL? Or
should I redesign my model and have Identification class having IdType
property instead?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.