流畅的NHibernate-ClassMap继承?

发布于 2024-10-04 04:50:14 字数 927 浏览 1 评论 0原文

在之前的问题中(与 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

为了传递它——但我不能。像这样的东西(虽然它本身没有意义)不起作用:

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

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

发布评论

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

评论(1

箹锭⒈辈孓 2024-10-11 04:50:14

好的,经过一番深入的谷歌搜索后,我找到了解决方案。希望这能帮助那些最终遇到与我相同情况的人:

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

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