部分加载 POCO
我有一个包含这些列的表
Id as integer
Name as string
Image as byte()
,然后我制作了两个 POCO
Public Class TableBase
Id as Integer
Name as String
End Class
Public Class Table
Inherts TableBase
Image as byte()
End Class.
因为我并不总是需要加载图像。 问题是我收到了一个歧视错误,并且 TPH 的解决方案无法解决它。因为我无法向数据库表添加区分列。
...
modelBuilder.Entity<Table>()
.Map(mc => mc.Requires("TableType").HasValue("Base"))
...
事实上我没有等级问题;我只需要部分加载 POCO
问候!
I have a Table with these columns
Id as integer
Name as string
Image as byte()
then I made two POCO
Public Class TableBase
Id as Integer
Name as String
End Class
Public Class Table
Inherts TableBase
Image as byte()
End Class.
Because I not always I need to load the image.
The problem is that I received a discrimination error, and the solutions of TPH stuff don’t resolve it. Because I can’t add a discrimination column to database table.
...
modelBuilder.Entity<Table>()
.Map(mc => mc.Requires("TableType").HasValue("Base"))
...
Actually I don’t have a hierarchy problem; I just need to load POCO partially
Regards!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要 TPH,因为在数据库中的 TPH 记录只能由一种实体类型表示 - 这意味着它将是
TableBase
或Table
,但绝不会两者兼而有之。您需要表格拆分。
You don't need TPH because in TPH record in the database can be represented by only one entity type - that means it will be either
TableBase
orTable
but never both.You need table splitting.