Hi!
Been wondering for a time how others usually deals with the parent
when mapping collections.
Say, we have a Group class which when its created should be filled
with users.
Group group = new Group("My new group");
IList<Users> users = Session.Get<User>();
group.AddMembers(users);
Would you in this mapping add a bidrectional mapping to users to get
which group they're in? Or would you just map the group-id to a
perhaps, maybe, a ParentID property on Users?
I'll find it hard to know when to use bidirectional mappings. Just
today i encountered a similar problem when adding children to a
parents collection which were mapped by the ID only on the child side.
//Code
public class Parent ...
public void AddChild(string childName, object[] OtherParams) {
Child c = new Child(childName, this, OtherParams); //Add "this" so we
know the parent
Children.Add(c);
}
and in the Child class
public class Child ...
public Child(string name, Parent parent, object[] otherParams) {
this.Name = name;
this.ParentId = parent.Id //Now this won't work cause the parent
hasn't been saved yet, could probably save the Parent in a private
variable and let the ParentId get property check that variable, Is it
possible to solve this with cascading?
}
So, hope I expressed myself god enough, english isn't my primary
language!
Thanks for any answers
//Kenny
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---