How to reference both entities when having only one column in one table in Fluent Nhibernate?

27 views Asked by At

So, I have two classes defined as such:

public class Booking {
     public virtual ID {get;set;}
     public virtual Room BookedRoom {get;set;}
     //....
}

public class Room {
     public virtual ID {get;set;}
     //....
}

public class BookingMap : ClassMap<Booking>{
        public BookingMap()
        {
             Table("Booking");
             Id(t=>t.ID).GeneratedBy.Identity();
             References(t=>t.BookedRoom).Column("IDBookedRoom");
        }

public class RoomMap : ClassMap<Room>{
        public RoomMap()
        {
             Table("Room");
             Id(t=>t.ID).GeneratedBy.Identity();
        }

I can easily access to Room via the Booking class, but I also need to reference the Booking class when handling Room.

I can't add a "IDBooking" on the Room table, and I need to both entities be related via one reference. Is this possible in Fluent NHibernate?

I tried to reference both entities via a foreign key, but it's not the ideal solution to my issue.

0

There are 0 answers