0

I have a table called openTickets. I have another table called openTicketFollowers that relates to it using a foreign key. OpenTickets does not know about openTicketFollowers but I want openTickets to have a property that is a list of its followers. Is there anyway to do this with fluent nhibernate?

user1989167
  • 63
  • 1
  • 1
  • 3

1 Answers1

1

Check this Fluent mapping document. The OpenTicket class will contain IList of Followers:

public class OpenTicket
{
  ...
  public virtual IList<OpenTicketFollower> Followers { get; set; }
}

public class OpenTicketFollowers
{
  public virtual OpenTicket OpenTicket { get; set; }
}

And this is fluent mapping of the OpenTicketFollowercollection:

HasMany(x => x.Followers)
  .KeyColumn("OpenTicketId");

and the OpenTicketFollower class mapping referencing the OpenTicket

References(x => x.OpenTicket)
  .Column("OpenTicketId")
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335