Private property mapping with fluent nhibernate

2019-03-28 08:27发布

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.

2条回答
ら.Afraid
2楼-- · 2019-03-28 08:32

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

查看更多
仙女界的扛把子
3楼-- · 2019-03-28 08:48

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.

查看更多
登录 后发表回答