0
我想带上属于个人资料或页面的帖子。两班同班,一对多关系
我怎样才能涉及到两类以外的同一类。
你推荐什么样的安排?
请帮帮我。
class Profile
{
public int ID { get; set; }
public string Name { get; set; }
public List<Post> Posts { get; set; }
}
class Page
{
public int ID { get; set; }
public string Name { get; set; }
public List<Post> Posts { get; set; }
}
class Post
{
public int ID { get; set; }
public string Description { get; set; }
public ProfileOrPage MyProperty { get; set; } //<<< My Problem Property
}
public void GetProfilePost()
{
List<Post> postList = new List<Post>();
postList.Add(new Post
{
ID = 1,
new ProfileOrPage { // My Problem Property
ID = 3
}
});
Profile p = new Profile();
p.Posts = postList;
}
添加您的上下文。什么是“我的问题属性”? –