BaseObject.EvaluateAlias<T>(String) Method
Calculates the value of a calculated property whose name is specified by the propertyName
parameter. The expression used in calculation must be specified through the PersistentAlias or Calculated attribute.
Namespace: DevExpress.Persistent.BaseImpl.EF
Assembly: DevExpress.Persistent.BaseImpl.EFCore.v24.2.dll
NuGet Package: DevExpress.Persistent.BaseImpl.EFCore
Declaration
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
propertyName | String | null | Specifies the name of a property value to be calculated. |
Type Parameters
Name | Description |
---|---|
T | The calculated property value type. |
Returns
Type | Description |
---|---|
T | The calculated property value. |
Remarks
Use the EvaluateAlias
method to calculate the value of a calculated property.
The propertyName
parameter specifies the name of a property value to be calculated. If this parameter is not specified and the EvaluateAlias
method is called in a property getter, the propertyName
parameter is automatically set to this property’s name.
The following code snippet uses the EvaluateAlias
method:
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
[DefaultClassOptions]
public class Payment : BaseObject {
[ModelDefault("DisplayFormat", "{0:c}")]
public virtual decimal Rate { get; set; }
public virtual decimal Hours { get; set; }
[ModelDefault("DisplayFormat", "{0:c}")]
[PersistentAlias("Rate * Hours")]
public decimal Amount {
// Ensure that the type parameter `T` is set to the type
// that matches the calculated expression result type.
get { return EvaluateAlias<decimal>(); }
}
}