6

I have this situation:

public namespace ANamespace
{
    public abstract class ABase:IABase
    {
        //properties
    }

    public abstract class A : ABase
    {
        //properties
    }

    public class A1 : A
    {
        //properties
    }

    public class A2 : A
    {
        //properties
    }
}

If I use this mapping code:

AutoMap
   .AssemblyOf<ABase>()
   .Where(e => e.Namespace == "ANamespace")
   .IncludeBase<A>().IgnoreBase<ABase>();

only A table is created (with ABase and A properties). If I delete IncludeBase() then A1 and A2 are created (with all properties).

AutoMap
   .AssemblyOf<ABase>()
   .Where(e => e.Namespace == "ANamespace")
   .IgnoreBase<ABase>();

How to write mapping to have tables for classes A (with all A and ABase properties), A1 and A2 (with specific properties) in my database but not for the class ABase?

0

1 Answer 1

2

After three days I finally found solution to this problem. It's not enough to have IncludeBase<T>(). You have to map base class too. So the solution is:

AutoMap
  .AssemblyOf<ABase>()
  .Where(type=>type.IsSubclassOf(typeof(A)) || type==typeof(A))
  .IncludeBase<A>();

I hope it will help some similar problems...

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.