Access Strategies

The access attribute is responsible for controlling the way NHibernate accesses the value of the property at run-time.

Below is the list of available values of the access attribute and their brief explanations.

Property - NHibernate uses the get/set accessors of the property. No naming strategy should be used with this access strategy because the value of the name attribute is the name of the property.
Field - NHibernate accesses the field directly and uses the value of the name attribute as the name of the field. This can be used when a property's getter and setter contain extra actions that needn't occur when NHibernate is populating or reading the object. If it is necessary that the name of the property rather than the field should be used by the consumers of your API with HQL, then a naming strategy is needed.
Nosetter - NHibernate accesses the field directly when setting the value and uses the Property when getting the value. This can be used when a property only exposes a get accessor because the consumers of your API can't change the value directly. A naming strategy is required because NHibernate uses the value of the name attribute as the property name and needs to be told what the name of the field is.
None - This value declares that the property should not be represented at the POCO level.

Note that default access for all properties in the model can be defined by selecting the appropriate value in the Default Access line of the model's properties.  

 


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.