kimsk112
unread,Nov 25, 2009, 12:09:52 PM11/25/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
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!