PropertyAccessMode PropertyAccessMode Enum

Definition

Pass a value from this enum to UsePropertyAccessMode(PropertyAccessMode), UsePropertyAccessMode(PropertyAccessMode), or UsePropertyAccessMode(PropertyAccessMode) to change whether the property or backing field will be used when reading and writing to a property or field.

If no access mode is set, then the backing field for a property will be used if possible when constructing new instances of the entity. The property getter or setter will be used, if possible, for all other accesses of the property. Note that when it is not possible to use the field because it could not be found by convention and was not specified using HasField(String), then the property will be used instead. Likewise, when it is not possible to use the property getter or setter, for example when the property is read-only, then the field will be used instead.

public enum PropertyAccessMode
Public Enum PropertyAccessMode

Fields

Field Field

Enforces that all accesses to the property must go through the field.

An exception will be thrown if this mode is set and it is not possible to read from or write to the field.

FieldDuringConstruction FieldDuringConstruction

Enforces that all accesses to the property must go through the field when new instances are being constructed. New instances are typically constructed when entities are queried from the database. An exception will be thrown if this mode is set and it is not possible to write to the field.

All other uses of the property will go through the property getters and setters, unless this is not possible because, for example, the property is read-only, in which case these accesses will also use the field.

This access mode is similar to the default mode used if none has been set except that it will throw an exception if it is not possible to write to the field for entity construction. The default access mode will fall back to using the property instead.

Property Property

Enforces that all accesses to the property must go through the property getters and setters, even when new objects are being constructed.

An exception will be thrown if this mode is set and it is not possible to read from or write to the property, for example because it is read-only.