I use NHibernate and Fluent NHibernate to create a mapping file for a domain object (although I don't care if the response uses free NHibernate or xml hbm syntax). And I'm having trouble figuring out how I indicate that the set of columns representing the component in the domain object is unique.
Here's the domain object:
public class SpaceLocation
{
public SpaceCoordinate Coordinates { get; set; }
public SpaceObject AtLocation { get; set; }
}
and here is the component I'm having problems with:
public struct SpaceCoordinate
{
public int x { get; set; }
public int y { get; set; }
public int z { get; set; }
}
Do not worry about SpaceObject AtLocationfor the purposes of this quesiton.
So, I know how to make a component from SpaceCoordinate, but I want to make sure that there are no duplicate inserts of the same set of coordinates. To do this, I want to make the component unique.
, , , :
public class SpaceLocationMap : ClassMapWithGenerator<SpaceLocation>
{
public SpaceLocationMap()
{
Component<SpaceCoordinate>(x => x.Coordinates, m =>
{
m.Map(x => x.x);
m.Map(x => x.y);
m.Map(x => x.z);
});
}
}
Fluent NHibernate , SpaceCoordinate. , , .
, hbm ?
, !