Skip to main content
.NET 6.0+

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.1.dll

NuGet Package: DevExpress.Xpo

Declaration

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class FetchOnlyAttribute :
    Attribute

Remarks

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; }
}
// ...  

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.

Inheritance

Object
Attribute
FetchOnlyAttribute
See Also