两个班级之间的关系

编程入门 行业动态 更新时间:2024-10-11 11:16:05
本文介绍了两个班级之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们如何维护实体框架中两个类之间的关系?

解决方案

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>

更多推荐

两个班级之间的关系

本文发布于:2023-07-14 10:35:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:班级   两个   关系

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!