问题描述
(与流利的NHibernate无关 - 由于我的问题,我已经切换了)我列出了一个表格布局问题,我在哪里需要根据来自哪个国家将我的列表实体分割到多个表中。这是出于性能方面的原因,我希望Listing_UK,Listing_FR等的表格。
现在,我认为我会用Fluent赢得大奖,而我是90 %那里 - 但我卡住了。我有一个Listing类和一个继承自它的Listing_UK类。例如:
列出testListing = new Listing_UK()as Listing b $ b
正常。但是,我已经绊倒了ClassMaps。我曾打算做一个静态的无效,将做所有的表像我们的映射:
pre $公共静态无效DoMap( ClassMap< Listing> map){
map.Id(x => x.ListingCode)
.GeneratedBy.HiLo(10000);
}
但是我需要将ClassMap< Listing_UK>到一个ClassMap< Listing>为了通过它,我不能。像这样的东西(尽管这样做没有意义)不起作用:
$ b $ pre $ ClassMap< Listing> test = new ClassMap< Listing_UK>作为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?
OK, I found a solution after some intensive Googling. Hopefully this will help someone who ends up in the same situation I did:
这篇关于流利NHibernate的ClassMap继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!