Hi Folks!
I have some problems where you might be able to help.
I try to map a class containing some lists, where the order is
relevant.
Code:
namespace NAMESPACE
{
public class CLASSNAME
{
...
private List<ITEMCLASS> internalCollection;
...
protected virtual ICollection<ITEMCLASS> PersistenceList
{
get
{
return internalCollection;
}
set
{
internalCollection.Clear();
internalCollection.AddRange(value);
}
}
...
}
}
when i use the following mapping it works:
Code:
<set name="PersistenceList" cascade="all-delete-orphan" generic="true">
<key column="KEYCOLUMN"/>
<one-to-many class="NAMESPACE.CLASSNAME, ASSEMBLY"/>
</set>
But since this mapping does not preserve the order of elements, i
tried to do this:
Code:
...
protected virtual IList<ITEMCLASS> PersistenceList
{
get
{
return internalCollection;
}
set
{
internalCollection.Clear();
internalCollection.AddRange(value);
}
}
...
with the following mapping:
Code:
<list name="PersistenceList" cascade="all-delete-orphan" generic="true">
<key column="KEYCOLUMN"/>
<index column="LISTINDEXCOLUMN"/>
<one-to-many class="NAMESPACE.CLASSNAME, ASSEMBLY"/>
</list>
Now the database tables for elements contained in the lists remains
empty after adding one element of the main class.
The data in the other properties of the main class is stored
correctly.
Is there anything i forgot to make it work?
Kind regards,
Christian