1.2.0
I've observed the following behavior while attempting to lazy-load an object that contains fields mapped using access="field.camelcase". I would appreciate it if someone could confirm that it is not a result of improper mapping and/or class creation.
Assuming this simplified mapping:
Code:
<class name="Foo">
<many-to-one name="Field" class="Bar" access="field.camelcase" />
</class>
The Foo class should look like this:
Code:
public class Foo
{
private Bar field;
public Bar Field
{
get {return field;}
set {field = value;}
}
}
If another class lazily initializes an instance of Foo, a proxy extending Foo is generated. Even though the property is not marked as virtual, based on my understading of the access="field.camelcase" attribute, this should be irrelevant to retrieving or setting the value of
field. Yet, after stepping through this precise scenario, any attempts to access
field always returns null. Inspecting the generated proxy via Visual Studio's debugger reveals that
field in the base class is, in fact, null. This same behavior occurs if
field is set to protected as opposed to private.
Now if I leave the mapping untouched but make the property virtual, accessing
field via the property works but
field in the generated proxy's base class is still null.
Is this behavior expected? If not, at what point does my understanding of direct field access break down?