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.v24.2.dll
NuGet Package: DevExpress.ExpressApp.EFCore
Declaration
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
public class PersistentAliasAttribute :
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
:
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.