xpo-devexpress-dot-xpo-5fd29dfc.md
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.v25.2.dll
NuGet Package : DevExpress.Xpo
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class FetchOnlyAttribute :
Attribute
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, Inherited:=True)>
Public NotInheritable Class FetchOnlyAttribute
Inherits Attribute
This attribute is helpful when you need to map XPO class properties/fields to:
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; }
}
// ...
Imports DevExpress.Xpo
' ...
<FetchOnly, Persistent(nameof(Total))>
Private _total As Double
<PersistentAlias(nameof(_total))>
Public ReadOnly Property Total() As Double
Get
Return _total
End Get
End Property
' ...
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.
Object Attribute FetchOnlyAttribute
See Also