user1989167
user1989167

Reputation: 63

Map list of items

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?

Upvotes: 0

Views: 43

Answers (1)

Radim Köhler
Radim Köhler

Reputation: 123861

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

Upvotes: 1

Related Questions