Search code examples
c#nhibernatefluent-nhibernatefluent-nhibernate-mapping

Fluent NHibernate Reveal not using given propertyname


I am trying to map the following protected collection in my class:

public class AddressList
{
    protected readonly IList<Address> addresses = new List<Address>();
}

With the following mapping:

HasMany<Address>(list => Reveal.Member<AddressList>("addresses"));

But I keep getting a NHibernate.MappingException

NHibernate.MappingException : Could not compile the mapping document: 
(XmlDocument) > NHibernate.PropertyNotFoundException 
: Could not find a getter for property '**Member**' in class

But as you can see in the Reveal.Member I am stating that the propertyname it should be looking for should be "addresses"

I have found this question, the user seems to have the same problem as me only it's an old question

I have also tried the solution given here


Solution

  • You should not use lambdas together with Reveal

    As you see in the exception message:

    NHibernate.MappingException : Could not compile the mapping document: (XmlDocument) > NHibernate.PropertyNotFoundException : Could not find a getter for property 'Member' in class

    I tries to map to a field named Member as you use list => Reveal.Member instead of just Reveal.Member