2

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.