Is this inheritance auto-mapping at all Possible?

alastair.todd's Avatar

alastair.todd

28 Apr, 2010 12:58 PM via web

Hi

I've done a bit of research and am still flapping about trying to find my end goal. Just wondering if someone can give me a one syllable answer to this:

I'm using auto-mapping. I have a number of abstract base classes:

public abstract class DomainObject
public abstract class AuditedDomainObject : DomainObject
public abstract class Organisation : AuditedDomainObject
public class Hospital : Organisation

Until recently this has worked just as I've needed. By adding

.IncludeBase()

To my automapper, everything works just as expected by convention. I get two one-one tables: Organisation and Hospital. This is needed as I have a level of abstraction where i need child relationships of Organisation.

I now want to specialise on Organisation and add another level of abstraction between Organisation and Hospital and Trust:

public abstract class Organisation : AuditedDomainObject
public abstract class ParentOrganisation : Organisation
public class ChildOrganisation : Organisation
public class Trust : ParentOrganisation
public class Hospital : ChildOrganisation

This is mapped directly to our domain: it is entirely possible to create a ChildOrganisation which isn't specialised or one that is: A Hospital. ParentOrganisations are always specialised hence it being abstract.

I wish to end up with these tables:
- Organisation - ChildOrganisation - Hospital - Trust

At the moment I get an error on schema generation: System.InvalidOperationException: Tried to add property 'Name' when already added.

'Name' is a property of Organisation - so it looks as if there's some knicker twisting going on, or more likely, i can't see the wood for the trees. Adding

.IgnoreBase< ParentOrganisation >()

had the same effect.

Thanks for any advice

  1. Support Staff 2 Posted by James Gregory on 16 May, 2010 05:29 PM

    James Gregory's Avatar

    There have been several fixes relating to automapping and inheritance recently, I would suggest you give the latest version a shot.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is the opposite of north?