0

我有一个需要包含自身相关实体的实体:

public class Period
{
public int ID {get; set;}
public DateTime StartDate {get; set;}
public DateTime EndDate {get; set;}  
public Period PriorPeriod {get; set;}  

}

如何仅使用 POCO 来实现这一点,或者这是否需要 Fluent API 映射?

4

1 回答 1

0
public class Period
{
    public int ID { get; set; }
    public int? PriorPeriodID { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }

    [ForeignKey("PriorPeriodID")]
    public Period PriorPeriod { get; set; }
}
于 2012-07-31T21:04:12.207 回答