hi, i', using nhibernate 3.1.0.4000.
i need to map a property of type sortedlist<t,k> (better) or
sortedlist.
i tried different cases but i always get same cast exception that
seems to be thrown becouse i can only map a property of type
idictionary
for example if i use this property
SortedList list = new SortedList();
private SortedList Data
{
get
{
return list;
}
set
{
list = value;
}
}
and map
<map name="Data" sort="natural" lazy="false">
<key column="Id"/>
<index column="KeyColumn" type="System.Int32"/>
<element column="ValueColumn" type="System.String"/>
</map>
i get this exception when tried to save an istance
System.InvalidCastException : Unable to cast object of type
'NHibernate.Collection.PersistentMap' to type
'System.Collections.SortedList'.
at
NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object
entity, Object[] values)
note:if i use collection-type="sorted-list" i get an exception
becouse nhibernate try to find the type sorted-list.
if i use the same map for the property
SortedList<int, string> list = new SortedList<int, string>();
private SortedList<int, string> Data {
get
{
return list;
}
set
{
list = value;
}
}
i get this exception
System.NullReferenceException : Object reference not set to an
instance of an object.
at NHibernate.Mapping.Map.get_CollectionType()
at NHibernate.Mapping.Collection.get_Type()
if i use the same property and add to the map collection-type="sorted-
list" i get this exception
System.InvalidCastException : Unable to cast object of type
'NHibernate.Collection.Generic.PersistentGenericMap`2[System.Int32,System.String]'
to type
'System.Collections.Generic.SortedList`2[System.Int32,System.String]'.
at
NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object
entity, Object[] values).
i'm doing samething wrong or nhibernate cannot manage a sortedlist
directly but only with idictionary interface?
thanks
note: reading the documentation at
http://nhforge.org/doc/nh/en/index.html#collections-sorted
seems that it's supported by nhibernate, at least for the not-generic
sortedlist
--
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.