I want to hide the primary key Id property from consumers of my entity classes:
public class A
{
protected virtual int Id { get; set; }
public virtual string Name { get; set; }
... etc ...
}
Making the Id property protected doesn't work with the standard Automapping, it fails to find it.
I tried overriding DefaultAutomappingConfiguration.IsId(...)
but this only gets called back with public members.
How can I get this to work without using specific ClassMap<A>
s for each type as documented here:
http://wiki.fluentnhibernate.org/Fluent_mapping_private_properties
EDIT:
I want to change the automapping conventions to look for any property with the name 'Id', not just public properties. I do not want to configure it on a per-class basis using ClassMap<T>
as follows:
public ClassAMap: ClassMap<A>
{
public ClassAMap()
{
Id(Reveal.Member<ClassAMap>("Id"));
}
}
public ClassBMap: ClassMap<B>
{
public ClassBMap()
{
Id(Reveal.Member<ClassBMap>("Id"));
}
}
... etc ...