OverrideAll with IgnoreProperties() does not obey abstract overridden or virtual overridden members in derived classes
If you consider the following base class and derived class:
public abstract BaseEntity
{
public virtual int Id { get; private set; }
public virtual string Message { get; set;}
public abstract string Title { get; }
public virtual bool HasTitle { get; }
}
public class DerivedEntity
{
public override string Title { get { return "My Title"; } }
public override bool HasTitle { get { return true; } }
}
And you use that with the following automapping scenario:
Fluently.Configure(
.Database (.... config goes here ...
.Mappings (m =>
m.AutoMappings
.Add(AutoMap.AssemblyOff<BaseEntity>()
.Where(t => t.Namespace == typeof(BaseEntity).Namespace)
.OverrideAll(map => map.IgnoreProperties("Title", "HasTitle"))
)
)
)
}
Then, when looking at the schema, Title
and HasTitle
will appear in it. Also, the "Property X needs a setter" error appears, but that naturally follows from the earlier erroneous behavior. I believe a workaround is to override the ShouldMap
member in IAutoMappingConfiguration
, but I haven't tried it yet.
Note 1: using an alternative OverrideAll
with, say, prop.Name.Contains("HasTitle")
still yields the same result: the ignore-request is ignored.
Note 2: I do use an .IgnoreBase(typeof(BaseEntity<>))
to ignore all properties of the base. These generic ignored bases contain the definitions of the properties, which are overridden in the subclasses. I haven't tested whether this triggers, or alters the above mentioned behavior.