实体框架多态 [英] Entity Framework Polymorphism
本文介绍了实体框架多态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在尝试使用Entity Framework实现简单的多态关系时,我需要一些帮助。
I wanted some help with trying to implement a simple polymorphic relationship using Entity Framework.
我想实现的关系示例:
评论表
- ItemType(视频,用户)
- ItemID
- 正文
视频有很多评论
用户有很多评论
不知道这样做的最佳方法,我来自Ruby on Rails的思维方式。
No idea the best way to do this, I come from a Ruby on Rails way of thinking.
推荐答案
这不需要多态性(继承)。
This does not call for polymorphism (inheritance).
您正确声明:视频有评论。继承需要:视频是评论。
You state correctly: Video has Comments. Inheritance would require: Video is a Comment.
这篇关于实体框架多态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文