Why does NHibernate require "secure internal" visibility on auto properties?

Previously, it was always possible to map auto properties to private setters with NHibernate, but since version 3.2 this is no longer the case (not without replacing the checking object), see the NH dev discussion .

I understand the requirement protected, but why internal? This breaks the encapsulation and just feels dirty.

Is the only alternative returning to fallback fields?

UPDATE : Embarassing, but right, it turns out, is internalnot required. Thus, he gets in between throwing back to the backup fields or using a secure setter and either avoids setting values ​​in the constructor or faces the risk of hard to track errors . Thanks to Fabio and @Nexus for pointing out my mistake.

+5
source share
3 answers

Michael

public string Foo { get; protected set; }it should be possible to discuss dev approximately public string Foo { get; private set; }, which can lead to errors when using lazy properties.

+6
source

NHibernate is pretty dirty. It uses reflection to access properties and fields.

private .

NHibernate , .

+1
public class Class{

    public string Foo { get; private set; }

}

Property(class=> class.Foo);

Then you need to disable proxy checking in your configuration:

Config.Proxy(p => {p.Validation = false});

+1
source

All Articles