MY SPELLING WAS REALLY TOO BAD. I HOPE I'VE JUST IMPROVED A LITTLE BIT.
Hi James thank you very much for your time.
I might be ok with Table per class hierarchy. Let's stick to that, though
now CodingAction can relate to other CodingAction, not just to a
TestingAction.
The real problemis still lies in Triple.
public Triple()
{
References(x => x.Project);
References(x => x.Coding);
References(x => x.Testing);
}
With the above mapping I cannot express that
x.Project +x.Coding must match an entry in Action table
x.Project +x.Testing must match an entry in Action table
That is my way to express that the relation between two Actions is bounded
to a single common Project.
Of course it is possible to go other ways: mainly triggers.
By the way I would like to underline that in MSSQL we could setup
the constarint - i.e. the 'must match' - provided we define a UNIQUE
constraint in th action table:
create table Action (
Id int,
Project_id int,
type varchar(200)
)
alter table Action add constraint uq...@project_id
unique(Id, Project_id)
go
This constraint is really odd actually: Id is the primary key so Id is
unique then (Id, Projectid) is certainly unique.
Never the less the existence of such an explicit unique key is required for
the action table to be referencable by (id,Project_id).
Once that is done I could set up the correct foreign key from Triple.
So the steps for solving
1. define a unique constraint on Action BTW this may be a little bit
different in case of other inheritance mappings (e.g the original one)
2. capability to use that Unique Key as the referenced Key in Triple.
I confess I have some troubles in achiving both. At lesat I have troubles
with 1 in my original setup.
Is all this stuff a bit artificial? well just a bit but not too much.
Finally I'd like to point out that If we define
public class Project:Entity{
IEnumerable<CodingAction> CodingActions {get; set;} /*to keep it short*/
IEnumerable<TestingAction> TestingActions {get; set;}
}
then the Joined Subclass thing comes out quite naturally.
Instead
public class Project:Entity{
IEnumerable<Action> Actions {get; set;} /*to keep it short*/
}
leads naturally to your set up.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---