流畅的NHibernate-ClassMap继承?
在之前的问题中(与 Fluent NHibernate 无关 - I'由于我的问题而切换)我概述了我遇到的表格布局问题,我需要根据它们来自哪个国家/地区将我的列表实体拆分到多个表格中。这是出于性能原因 - 实际上,我想要 Listing_UK、Listing_FR 等的表。
现在,我以为我会用 Fluent 中大奖,而且我已经完成了 90% - 但我陷入了困境。我有一个 Listing 类和一个继承它的 Listing_UK 类。因此,类似:
Listing testListing = new Listing_UK() as Listing
工作正常。然而,我在 ClassMap 上犯了错误。我本来打算创建一个静态 void 来为所有表进行映射,如下所示:
public static void DoMap(ClassMap<Listing> map) {
map.Id(x => x.ListingCode)
.GeneratedBy.HiLo("10000");
}
但我需要将 ClassMap
ClassMap<Listing> test = new ClassMap<Listing_UK> as ClassMap<Listing>
有什么想法我可以优雅地处理这个问题吗?
In an earlier question (unrelated to Fluent NHibernate- I've switched as a result of my problem) I outlined a table layout issue I'm having where I need to split my Listing entities across a number of tables depending on what country they're from. It's for performance reasons- effectively, I want tables for Listing_UK, Listing_FR, etc.
Now, I thought I'd hit the jackpot with Fluent, and I'm 90% there- but I've got stuck. I have a Listing class, and a Listing_UK class that inherits from it. As such, something like:
Listing testListing = new Listing_UK() as Listing
works fine. However, I've tripped up on the ClassMaps. I had intended to make a static void that'll do my mapping for all the tables like so:
public static void DoMap(ClassMap<Listing> map) {
map.Id(x => x.ListingCode)
.GeneratedBy.HiLo("10000");
}
but I need to convert the ClassMap<Listing_UK> to a ClassMap<Listing> in order to pass it in- and I can't. Something like this (though it doesn't make sense, as such) doesn't work:
ClassMap<Listing> test = new ClassMap<Listing_UK> as ClassMap<Listing>
Any ideas how I can gracefully handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,经过一番深入的谷歌搜索后,我找到了解决方案。希望这能帮助那些最终遇到与我相同情况的人:
http://geekswithblogs.net/nharrison/archive/2010/07/09/inheriting-a-class-map-in- Fluent-nhibernate.aspx
OK, I found a solution after some intensive Googling. Hopefully this will help someone who ends up in the same situation I did:
http://geekswithblogs.net/nharrison/archive/2010/07/09/inheriting-a-class-map-in-fluent-nhibernate.aspx