[英]EF 6 Navigation property between two objects of the same type
I have a EF db model called Booking 我有一个名为Booking的EF数据库模型
public class Booking
{
public int ID { get; set; }
public string Name { get; set; }
// some other properties...
}
I need to be able to link two different bookings together, how can create a navigation property that gives me a link between each booking? 我需要将两个不同的预订链接在一起,如何创建一个导航属性,使我在每个预订之间建立链接?
Eg, Booking A needs a navigation property to Booking B and vice versa, Booking B needs a navigation property to Booking A. 例如,预订A需要导航属性到预订B,反之亦然,预订B需要导航属性到预订A。
Thanks. 谢谢。
I guess you could do like another navigation property: 我想你可以像另一个导航属性一样:
public class Booking
{
// Your current code and...
// If you want One to One:
public virtual Booking RelatedBooking { get; set; }
// but if it's One to Many:
public virtual ICollection<Booking> RelaitedBookings { get; set; }
}
I hope it helps. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.