Mapping a list of custom value types (ICompositeUserType)
Hi,
I have a class Point3D and also a (class Point3DValueMapper : ICompositeUserType) which specifies how this is persisted as a value type. I am able to Map a single point using Map(x => x.singlePoint).CustomType(typeof(Point3DValueMapper));
I now have a member which represents a collection of Point3D classes (IList listOfPoints) which I would like to persist. How can I go about doing this? I have tried to delve into the lambdas but got lost pretty quickly.
I briefly considered attempting to map it using HasMany(x=> x.listOfPoints).Component( d => d.Map(pt => pt.X)) but this complains about a lack of setter for property X for Point3D. This makes sense as Point3D is an immutable type and is more appropriatelly managed as a valuetype.
I've read a seemingly related post here http://www.mail-archive.com/***@googlegroups.com/msg0... but I can't quite follow what they are doing.
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Andy Foster on 06 May, 2010 03:59 PM
HasMany(x=> x.listOfPoints).Elements("X", element => { element.Columns.Add("Y"); element.Columns.Add("Z"); element.Type(); });
This will work for Point3DValueMapper which exposes 3-tuples of PropertyNames/PropertyTypes
Thanks all for your help.
James Gregory closed this discussion on 16 May, 2010 05:17 PM.