You should use your own implementation of
 ICandidatePersistentMembersProvider and inject it to the ModelMapper
instead change the default behavior.
The default behavior is based on the mostly used use-case where protected
and private members are not mapped.
If you are using "ExplicitlyDeclared" mapping, then you can implement any
kind of extensions to return a MemberInfo.
I can't remember where it is but I'm pretty sure that we have already a way
to map private members explicitly.

On Tue, Aug 21, 2012 at 7:07 PM, Rory Plaire <[email protected]> wrote:

> I've converted our XML mapping to NH 3.3.1 By Code mapping and ran into 2
> restrictions which seem to be unwarranted, since they do not exist in the
> XML mapping. Both result from reflecting on classes with methods on
> NHibernate.Mapping.ByCode.TypeExtensions.
>
>
>    1. In *DecodeMemberAccessExpressionOf<TEntity>(Expression<Func<TEntity,
>    object>> expression)* and *DecodeMemberAccessExpressionOf<TEntity,
>    TProperty>(Expression<Func<TEntity, TProperty>> expression)*, there
>    are calls (line 104 and 157 respectively) which get the PropertyInfo from
>    the entity type. This is restricted to public-only due to the default
>    binding level of the GetProperty method. XML mapping doesn't have this
>    restriction, and properties can be protected or internal. We use this
>    extensively to reduce the surface area of our domain model. I changed the
>    call to accept non-public members and the NH unit tests still pass.
>    2. In *DetermineDictionaryKeyType* and *DetermineDictionaryValueType*,
>    the parameter is a Type which is tested for being a generic type via
>    IsGenericType. This property only returns true if the reflected type has
>    type parameters. We've specialized an IDictionary<K,V> and was able to map
>    it in XML, but not in By Code due to the conditional:* if
>    (genericDictionary.IsGenericType)*. Given that the
>    GetDictionaryInterface method extracts the dictionary interface and
>    performs the same test as this condition, why add this condition? I removed
>    this conditional in both cases and the NH unit tests still pass.
>
> As noted, I fixed both these issues to get my mapping working, and if they
> are confirmed to be problems, I can enter a Jira issue and push a patch on
> my fork and send a pull request.
>
> -rory
>



-- 
Fabio Maulo

Reply via email to