Is there any way to avoid a property from being mapped with NHibernate 3.2 using mapping by code conventions? By default, all properties are mapped.
2) As alternative to copy&paste of default implementation of IsPersistentProperty it can be reused via reflection:
var mapper = new ConventionModelMapper();
var field = mapper.ModelInspector.GetType()
.GetField( "isPersistentProperty", BindingFlags.NonPublic | BindingFlags.Instance );
var ispp = (Func<MemberInfo, bool, bool>)field.GetValue( mapper.ModelInspector );
mapper.IsPersistentProperty( ( mi, b ) => ispp( mi, b )
&& ( /*any conditions here*/ mi.Name != "SomeFiledName" ) );
Conditions can be moved to separate method or class. An stronly-typed wrapper based on expressions can be done above it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With