6

I am getting exception mapping a private property.This is the situation: I have this in Entity.cs: privat int m_Inactive;

and in EntityMap.cs I have :

Map(x => Reveal.Property<Entity>("m_Inactive")).ColumnName.("INACTIVE"); 

But I get this error:

System.Reflection.TargetInvocationException: Exception has been thrown 
by 
the target of an invocation. --->  System.ArgumentException: Not a member access 

What could be the reason?

Thanks.

frictionlesspulley
  • 11,070
  • 14
  • 66
  • 115

2 Answers2

14

If you follow the examples on the wiki you'll see that you're supposed to use Map(Reveal.Member<YourEntity>("m_Inactive")).

James Gregory
  • 14,173
  • 2
  • 42
  • 60
  • The link is outdated. The updated one is: http://wiki.fluentnhibernate.org/Fluent_mapping_private_properties and http://wiki.fluentnhibernate.org/Mapping_a_collection_that_uses_a_private_backing_field – sumek Mar 03 '10 at 09:58
  • I've recently moved servers and had forgot to re-create the url redirects. Thanks for reminding me! Both the old and the new link are working now. – James Gregory Mar 03 '10 at 14:06
  • 1
    Links broken again, use this link: https://github.com/jagregory/fluent-nhibernate/wiki/Mapping-private-properties –  Jul 05 '12 at 17:22
2

Looks like in the latest version you're supposed to use Reveal.Member since Reveal.Property is obsolete:

Map(Reveal.Member<YourEntity>("m_Inactive"))

Oh, and sort of a "duh" but you'll need to make sure you include FluentNHibernate:

using FluentNHibernate;

And another "duh" but this will work with protected members as well as private.

longda
  • 10,153
  • 7
  • 46
  • 66