I am trying to understand how to map a component as a primary key in nhibernate and, if possible, in free nhibernate.
This component is a unique set of three-dimensional coordinates, here is the object:
public class SpaceLocation
{
public virtual SpaceCoordinate Coordinates { get; set; }
public virtual SpaceObject AtLocation { get; set; }
}
SpaceCoordinate is a structure defined as follows:
public struct SpaceCoordinate
{
public int x { get; set; }
public int y { get; set; }
public int z { get; set; }
}
In free nhibernate, to make SpaceCoordinate a command, I would create a display class as follows:
public class SpaceLocationMap : ClassMapWithGenerator<SpaceLocation>
{
public SpaceLocationMap()
{
References(x => x.AtLocation);
Component<SpaceCoordinate>(x => x.Coordinates, m =>
{
m.Map(x => x.x);
m.Map(x => x.y);
m.Map(x => x.z);
}).Unique();
}
}
But I would like to know how to make the SpaceCoordinate component as a whole a primary key with its unique restriction. How do I map this in Nhibernate xml or in the free nhibernate class map?