There are 2 classes: Product and Image.
This represent composition relationship in UML which means:
Assigning Product.Image a newImage results in following
Now I need to map it to the RDBMS tables (meta-code):
Product (Id primary key, ImageId int references Image(id))
Image(Id primary key, Content)
The question is HOW to do it using Fluent NHibernate.
PLEASE NOTE:
productMap.References(x => x.Image).Cascade.All()
is not applicable - it DOES NOT delete the orphan image.
Also NH DOES NOT support all-delete-orphan for many-to-one, on-to-one.
I probably need something like join with component...
BUT IN FLUENT NH.
UPDATE: James in FNH user groups suggested this syntax:
WithTable("other table", m =>
{
m.Component(...);
});
But no luck with it: NotSupportedException: Obsolete
It supposed to work in v1 (upcomming) of FNH.
You can map like a component ?
Mapping with Fluent : http://wiki.fluentnhibernate.org/show/StandardMappingComponents
NH doc : http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-component