If you need to do this, your map are wrong, you need to create a ClassMap to Parent, and don't map this property "something", and create two differents mappings for children, one that contains "something" property and one that does not contain.
Don't map property in SubClass
-
18-10-2022 - |
Question
Is it possible to tell Fluent NHibernate not to map a property in a SubClassMap
which is defined in it's parent's ClassMap
? So:
public class ParentMap : ClassMap<Parent>
{
public ParentMap()
{
this.Map(x => x.Id);
this.HasManyToMany(x => x.Somethings)
.Table("ParentSomethings")
.ParentKeyColumn("ParentId")
.ChildKeyColumn("SomethingId");
this.DiscriminateSubClassesOn("Foo");
}
}
public class ChildMap : SubclassMap<Child> // with Child : Parent
{
this.DiscriminatorValue("Child");
this.DontMap(x => x.Somethings); // fictional method
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow