Also please check out Ayende's post on the map element. His first example of map's use is very close to what you are trying to achieve.
http://ayende.com/blog/4045/nhibernate-mapping-map Regards Michael On Saturday, 3 March 2012 21:40:12 UTC, Arcreme wrote: > > I am trying to map the following SortedList: > > ... > private SortedList<DateTime, string> _data; > public virtual SortedList<DateTime, string> Data > { > get { return _data; } > set { _data = value; } > } > > ... > <map name="Data" sort="natural"> > <key column="EntityId" /> > <index column="time" type="DateTime" /> > <element column="value" type="String" /> > </map> > ... > > However when I try to create a session factory using > Configuration.BuildSessionFactory() I get a NullReferenceException: > > --NullReferenceException > at NHibernate.Mapping.Map.get_CollectionType() in d:\CSharp\NH\NH > \nhibernate\src\NHibernate\Mapping\Map.cs: line 33 > > If I omit the sort attribute (which I belive I shouldn't according to > the manual) in the map element i get a > NHibernate.PropertyAccessException: > > System.InvalidCastException : Unable to cast object of type > 'NHibernate.Collection.Generic.PersistentGenericMap`2[System.DateTime,System.String]' > > > to type > 'System.Collections.Generic.SortedList`2[System.DateTime,System.String]'. > > I also to have the sort attribute to point to a implementation of the > IComparer interface, but I still get the NullReferenceException. > > Any ideas on how to succesfully map a SortedList? > > Thank you. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/81_Ux9dYUHUJ. 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.
