NHibernate: Map one class to two identical tables

此生再无相见时 提交于 2019-12-04 06:10:14

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/2041567/nhibernate-map-one-class-to-two-identical-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!