Back to Devexpress

PersistentAliasAttribute Class

expressappframework-devexpress-dot-expressapp-dot-dc-437ef25c.md

latest3.2 KB
Original Source

PersistentAliasAttribute Class

Applies to EF Core business class properties. Specifies an expression used to calculate the target property value.

Namespace : DevExpress.ExpressApp.DC

Assembly : DevExpress.ExpressApp.EFCore.v25.2.dll

NuGet Package : DevExpress.ExpressApp.EFCore

Declaration

csharp
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
public class PersistentAliasAttribute :
    CalculatedAttribute
vb
<AttributeUsage(AttributeTargets.Property, Inherited:=True)>
Public Class PersistentAliasAttribute
    Inherits CalculatedAttribute

Remarks

Use the PersistentAliasAttribute to specify an expression used to calculate the value of a calculated property.

In an EF Core business class, a property decorated with the PersistentAliasAttribute works like a regular property in all data access modes. Note that for an EF Core class property, the PersistentAliasAttribute has the same effect as the CalculatedAttribute.

The following code snippet uses the PersistentAliasAttribute:

csharp
using DevExpress.ExpressApp.DC;
// ...
public class Person : BaseObject {
    // ...
    public virtual String FirstName { get; set; }
    public virtual String LastName { get; set; }
    [PersistentAlias("Concat(FirstName, ' ', LastName)")]
    public String FullName {
        get {
            get { return EvaluateAlias<String>(); }
        }
    }
}
// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

The expression specified through the CalculatedAttribute.Expression parameter is calculated on the database server side. The expression can reference persistent properties, other calculated properties, or criteria functions that can be executed by the database server through SQL.

Inheritance

Object Attribute CalculatedAttribute PersistentAliasAttribute

See Also

PersistentAliasAttribute Members

EvaluateAlias

Calculate a Property Value Based on Values from a Detail Collection in EF Core

DevExpress.ExpressApp.DC Namespace