Reputation: 9603
This is probably a very simple question but I'm new to nHibernate and I'm having trouble working this out.
I have a Page object, which can have many Region objects. I also have a Workflow object. Page and Region objects both have a relationship to Workflow and it's this double association that I'm having trouble with.
The PageMap has
HasMany(Function(x) x.Regions).Cascade.All()
And the RegionMap has:
References(Function(x) x.Page)
And this all seems to work.
But how do I define the relationship between Workflow and these two objects?
Upvotes: 0
Views: 36
Reputation: 72840
How is it in your database? If both have a foreign key to workflow, then both get a Workflow
property mapped as:
References(Function(x) x.Workflow)
in each mapping class. If only the Page
has it, and the Region
's is therefore inferred, add an unmapped readonly property on Region
thus:
public Workflow Workflow { get { return Page.Workflow; } }
Upvotes: 1