我在ASP.NET核心中编写了以下代码。我想在Post
列之上的表Interview
和interview_id
之间建立连接。我怎么能这样做?
public class Post {
[Display(Name = "Post Title")]
[Required]
[DataType(DataType.Text)]
public long interview_id { get; set; }
public int visa_type_id { get; set; }
public DateTime Posted { get; set; }
public string story { get; set; }
public bool gotten { get; set; }
}
public class Interview {
[Display(Name = "Post Title")]
[Required]
[DataType(DataType.Text)]
public long Id { get; set; }
public int interview_id { get; set; }
public DateTime Posted { get; set; }
public string question { get; set; }
public string answer { get; set; }
}
答案 0 :(得分:0)
如果您想要一对一的关系,您只需在表类中添加相关实体:
public class Post
{
public long interview_id { get; set; }
public Interview Interview { get; set; }
}
// if you want two way relation
public class Interview
{
public long post_id { get; set; }
public Post Post { get; set; }
}