I've gone with this...

01: Direct access to the field on the parent

    <set name="comments" access="field" cascade="all-delete-orphan"
inverse="true">
      <key column="BlogEntry"/>
      <one-to-many class="Comment"/>
    </set>

02: A ReadOnlyList for accessing the children

                private ISet<Comment> comments = null;
                public ReadOnlyCollection<Comment> Comments
                {
                        get { return new List<Comment>(comments).AsReadOnly(); }
                }

03: With Internal access to add/remove items

                internal void AddComment(Comment comment)
                {
                        comments.Add(comment);
                }

                internal void RemoveComment(Comment comment)
                {
                        comments.Remove(comment);
                }


04: Child ensures in-memory consistency at the cost of having to load
the original parent object when it might not be required.

                private BlogEntry blogEntry;
                public BlogEntry BlogEntry
                {
                        get { return blogEntry; }
                        set
                        {
                                if (BlogEntry != null)
                                        BlogEntry.RemoveComment(this);
                                blogEntry = value;
                                if (BlogEntry != null)
                                        BlogEntry.AddComment(this);
                        }
                }


If anyone has any comments please let me know.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to