FetchOnlyAttribute Class
Applied to persistent properties and fields. When applied, specifies that the target property or field value can be loaded from the database but should not be saved (should not be included in the INSERT and UPDATE SQL statements).
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.2.dll
Declaration
Remarks
This attribute is helpful when you need to map XPO class properties/fields to:
- computed database columns (when it is inefficient to implement them as read-only using PersistentAliasAttribute);
- auto-increment database columns that are not primary keys (for example, rowversion).
You can decorate a property/field with the FetchOnlyAttribute directly in code or using the Data Model Designer.
using DevExpress.Xpo;
// ...
[FetchOnly]
[Persistent("Total")]
private double _total;
[PersistentAlias(nameof(_total))]
public double Total {
get { return _total; }
}
// ...
The designer applies this attribute when you enable the Fetch Only option. In the metadata (see XPTypeInfo), the XPMemberInfo.IsFetchOnly property returns True for members with this attribute.
Note
In a NestedUnitOfWork, the attribute’s target property/field value is not passed to the parent session.