Hello,
I’m using two business classes with corresponding map files and DB tables on a SQL server.
One class is a “Parent” and the second one is “Child”. This means the parent can have many children (one-to-many relation) and a child has only one parent (many-to-one relation).
The child table on DB has a foreign key pointing to the parent table to match the relation
Many-to-one.
On the Parent class I have a HashedSet() which contains the Child with the following property :
public
Iesi.Collections.ISet ChildList
{
get
{
if (m_ChildList==null)
{
m_ChildList = new Iesi.Collections.HashedSet();
}
return m_ChildList;
}
set { m_ChildList = value; }
}
Everything is working as I want, when I save the parent the corresponding child are also automatically set with the cascade option to the DB, but….
The only small thing I would like to have is an access to the Child object on the Childlist by using a Hashtable and a key, I know the HashedSet is in fact working with a Hashtable but this one is not accessible.
My first question is about this internal HashedSet Hashtable, (InternalDictionary) how are they the keys generated ?
Is it possible to replace Iesi.Collections.HashedSet() by a standard Hashtable (and of course keeping the cascaded update on children ?)., I place the IDictionary interface on my property related to the Hashtable but I got an exception when cascading…
Where and how to specify a key used when we get data (Children) from the DB to fill a simple hashtable ?
May be it exists another way to use Hashtables with NHibernate ?
Another wish is to avoid to add an extra table (kind of join table) on the DB for saving the hashtable…
I’m really starting with NHibernate so I’m afraid to miss something really obvious.
Thanks for your replies…
|