I tried tracking in FluentNHibernate's code exactly why IgnoreProperty seems to break when the ignored property comes from the base class, but the time runs out. It seems to work fine if the get-only property does not come from the base class.
In any case, the solution to your situation seems to be to create a custom IAutomappingConfiguration by inheriting from DefaultAutomappingConfiguration. See This Answer: How to create a Fluent NHibernate Convention that ignores properties that have no setters .
Here's a custom auto-configuration configuration that I have successfully used to automate the instance of the example you provided:
protected class CustomConfiguration : DefaultAutomappingConfiguration { public override bool ShouldMap (Member member) { if (member.IsProperty && member.IsPublic && !member.CanWrite) { return false; } return base.ShouldMap(member); } public override bool ShouldMap(Type type) { return type.Namespace != null && type.Namespace.Contains("Models"); } }
And then its use:
var autoMap = AutoMap .AssemblyOf<DomainEntity>(new CustomConfiguration());
Note that the Where clause in your example should move to a custom configuration class, since it cannot be resolved if you use an instance of a custom configuration.
Nfrank
source share