Hi,
There are 2 classes: Product and Image.
- The Product has only one Image.
- No orphan Images can exist.
This represent composition relationship in UML which means:
Assigning Product.Image a newImage results in following
- delete old image;
- insert new image;
- link new image to the product.
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.