本文介绍了两个班级之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何维护实体框架中两个类之间的关系?
解决方案public class 博客 { public int BlogId { get ; set ; } public string 名称{ get ; set ; } public virtual 列表< post>帖子{获取; set ; } } public class 发布 { public int PostId { get ; set ; } public string 标题{ get ; set ; } public string 内容{ get ; set ; } public int BlogId {获得; set ; } public 虚拟博客博客{ get ; set ; } } < / 发布 >
How can we maintain the relationship between the two classes in the entity frame work?
解决方案 public class Blog { public int BlogId { get; set; } public string Name { get; set; } public virtual List<post> Posts { get; set; } } public class Post { public int PostId { get; set; } public string Title { get; set; } public string Content { get; set; } public int BlogId { get; set; } public virtual Blog Blog { get; set; } }</post>更多推荐
两个班级之间的关系
发布评论