I've got this question that's been bugging me and my vast and
unfathomable intellect just can't grasp it. The case: I want to make
multiple one-to-many relationships to the same entity using the fluent
nhibernate automapper and export schema.

I have:

Base Class:

 public abstract class Post<T> : Entity, IVotable, IHierarchy<T>
 {
    public virtual string Name
    {
        get; set;
    }

    public virtual string BodyText
    {
        get; set;
    }

    public virtual Member Author
    {
        get; set;
    }
}
and Inheriting Class:

 [Serializable]
public class WallPost : Post<WallPost>
{
    public virtual Member Receiver
    {
        get; set;
    }
}
The 'Member' properties of WallPost is a foreign key relationship to
this class:

public class Member : Entity
    {
        public Member()
        {
           WallPosts = new IList<WallPost>();
        }

 public virtual IList<WallPost> WallPosts
        {
            get; set;
        }
}
I hope you're with me until now. When I run the exportschema of
nhibernate I expect to get a table wallpost with 'author_id' and
'receiver_id' BUT I get author_id, receiver_id,member_id. Why did the
Nhibernate framework add member_id, if it's for the collection of
posts (IList) then how do you specify that the foregin key
relationship it should use to populate is receiver, i.e.
member.WallPosts will return all the wallposts of the receiver.

I hope i made sense, if you need anything else to answer the question
let me know and I'll try to provide.

Thanks in advance

P.s. If I change the property name from 'Receiver' to 'Member' i.e.
public virtual Member Member, only two associations are made instead
of 3, author_id and member_id.

E

-- 
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