部分加载 POCO

发布于 2024-11-28 10:43:18 字数 540 浏览 6 评论 0原文

我有一个包含这些列的表

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最舍不得你 2024-12-05 10:43:18

您不需要 TPH,因为在数据库中的 TPH 记录只能由一种实体类型表示 - 这意味着它将是 TableBaseTable,但绝不会两者兼而有之。

您需要表格拆分

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 or Table but never both.

You need table splitting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文