I have some bi-directional associations and wonder if anybody knows if
there are any drawbacks or good reasons not to do like this:
On the parent, I use these methods for adding to the collection:
public virtual void AddAutomaticControl(AutomaticControl item)
{
RelationManager.AddToList(x => x.AutomaticControls, item,
x => x.Building, this);
}
public virtual void RemoveAutomaticControl(AutomaticControl
item)
{
RelationManager.RemoveFromList(x => x.AutomaticControls,
item, x => x.Building, this);
}
On the child the property goes like this:
public override Building Building
{
get { return building; }
set { RelationManager.Relate(ref building, value, x =>
x.AddAutomaticControl(this), x => x.RemoveAutomaticControl(this)); }
}
The RelationManager makes sure, that if I add an entity to the
collection the reference on the child is set, and visa versa.
Does anybody know if that's a good idea, or does it have implications,
I'm not aware of?
I've read somewhere that it might be best to avoid bi-directional
associations all together. Good reasons for that?
Any comments are appreciated :)
/Asger
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.