Hello,

I'm trying to map the following:

A user can be connected to another user. The user class has a
'Connections' property which a collection of UserConnection. A
UserConnection has two references to User, one for the requester (he
who initiated the connection) and one for the requestee (he who is the
target of the connection).

Using FluentNHibernate I want to load all UserConnections for when
loading the User. A User's connections are those where the user's id
matches either the requesterId or the requesteeId.

public class User
{
    //....
    public virtual IList<UserConnection> Connections { get; set; }
}

public class UserConnection
{
    //....
    public virtual User Requester { get; set; }
    public virtual User Requestee { get; set; }
}

At the moment I have mapped this using two collections:

HasMany(x => x.IncomingConnections).Key(k =>
k.Columns.Add("Requestee_id")).Fetch.Select().Not.LazyLoad();
HasMany(x => x.OutgoingConnections).Key(k =>
k.Columns.Add("Requester_id")).Fetch.Select().Not.LazyLoad();

This results in two selects, and that's what I'd like to avoid. Can
you help?

Note: I've also posted this on StackOverflow:http://stackoverflow.com/
questions/5515519/mapping-on-one-of-two-columns-many-to-many-mapping-
with-fluentnhibernate

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