NHibernate:将一个类映射到两个相同的表
我需要将一个实体映射到两个表(Invoice 和 InvoiceHistory)。我不能将两个数据库表合并为一个并添加一个状态列来区分它们。
这两个表具有完全相同的结构,但是,正如名称所示,InvoiceHistory 保留旧发票的历史记录,而 Invoice 存储活动发票。 (确切的实体不是发票,但我不允许透露细节,而且我认为它们无论如何都不相关)。
I need to map one entity to two tables (Invoice and InvoiceHistory). It's not up to me to merge the two database tables in one and add a status column to differentiate them.
The two tables have the exact same structure, but, as the name says, InvoiceHistory keeps a history of old invoices whereas Invoice stores active invoices. (the exact entity is not invoice but I am not allowed to disclose details plus I don't think they would be relevant anyway).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建另一个实体,该实体继承您创建的第一个实体并且不执行任何其他操作。然后,您可以将新实体映射到 InvoiceHistory,而第一个实体仍映射到 Invoice。
Create another entity which inherits the first entity you created and does nothing else. You can then map the new entity to InvoiceHistory, while the first one is still mapped to Invoice.