using System.Reflection;

namespace NHibernate.Mapping.ByCode.Impl.CustomizersImpl
{
	public class ComposedIdCustomizer<TEntity> : PropertyContainerCustomizer<TEntity>, IComposedIdMapper<TEntity> where TEntity : class
	{
		public ComposedIdCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, ICustomizersHolder customizersHolder)
			: base(explicitDeclarationsHolder, customizersHolder, null) {}

		protected override void RegisterPropertyMapping<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Action<IPropertyMapper> mapping)
		{
			MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
			ExplicitDeclarationsHolder.AddAsPartOfComposedId(member);
			base.RegisterPropertyMapping(property, mapping);
		}

		protected override void RegisterManyToOneMapping<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Action<IManyToOneMapper> mapping)
		{
			MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
			ExplicitDeclarationsHolder.AddAsPartOfComposedId(member);
			base.RegisterManyToOneMapping(property, mapping);
		}
	}
}
using System.Reflection;

namespace NHibernate.Mapping.ByCode.Impl.CustomizersImpl
{
	public class ComposedIdCustomizer<TEntity> : PropertyContainerCustomizer<TEntity>, IComposedIdMapper<TEntity> where TEntity : class
	{
		public ComposedIdCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, ICustomizersHolder customizersHolder)
			: base(explicitDeclarationsHolder, customizersHolder, null) {}

		protected override void RegisterPropertyMapping<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Action<IPropertyMapper> mapping)
		{
			MemberInfo member = TypeExtensions.DecodeMemberAccessExpressionOf(property);
			ExplicitDeclarationsHolder.AddAsPartOfComposedId(member);
			base.RegisterPropertyMapping(property, mapping);
		}

		protected override void RegisterManyToOneMapping<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Action<IManyToOneMapper> mapping)
		{
			MemberInfo member = TypeExtensions.DecodeMemberAccessExpressionOf(property);
			ExplicitDeclarationsHolder.AddAsPartOfComposedId(member);
			base.RegisterManyToOneMapping(property, mapping);
		}
	}
}
Fix for superclass properties (NH-3318)
Fix for superclass properties (NH-3318)

When obtained straight from a lambda expression, MemberInfo for a
superclass property has both DeclaringType and ReflectedType set to
Superclass. This causes problems when ModelMapper goes through
properties - their ReflectedType is Subclass. Turns out there was an
alternative, more thorough way of getting to that in NH codebase
already.
