Mapping a list of custom value types (ICompositeUserType)

Andy Foster's Avatar

Andy Foster

27 Apr, 2010 04:55 AM via web

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.

  1. 2 Posted by Andy Foster on 06 May, 2010 03:59 PM

    Andy Foster's Avatar

    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.

  2. James Gregory closed this discussion on 16 May, 2010 05:17 PM.

Comments are currently closed for this discussion. You can start a new one.