FluentNHibernate: multiple one-to-many relationships between the same entities.

Posted by Venemo on Stack Overflow See other posts from Stack Overflow or by Venemo
Published on 2010-05-05T22:13:18Z Indexed on 2010/05/05 22:18 UTC
Read the original article Hit count: 184

Hi,

I'm working on a bug tracking application. There are tickets, and each ticket has an opener user and an assigned user. So, basically, I have two entities, which have two many-to-one relationships with each other. Their schematic is this:

User:

public class User
{
    public virtual int Id { get; private set; }

    ...

    public virtual IList<Ticket> OpenedTickets { get; set; }

    public virtual IList<Ticket> AssignedTickets { get; set; }
}

Ticket:

public class Ticket
{
    public virtual int Id { get; protected set; }

    ...

    [Required]
    public virtual User OpenerUser { get; set; }

    public virtual User AssignedUser { get; set; }
}

I use FluentNHibernate's auto mapping feature.

The problem is, that no matter whether relationship I set, on the side of the User, both collections always contain the same data. I guess Fluent can't tell which end of which relationship belongs to where.

I googled around but haven't found anything useful.

Could anyone help me, please?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about nhibernate