Reputation: 63
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
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 OpenTicketFollower
collection:
HasMany(x => x.Followers)
.KeyColumn("OpenTicketId");
and the OpenTicketFollower
class mapping referencing the OpenTicket
References(x => x.OpenTicket)
.Column("OpenTicketId")
Upvotes: 1