XPO特性PersistentAlias
电脑版发表于:2020/12/2 10:40
指定字段和属性之间的关联。通过保留相应的字段来存储属性的值。
public decimal UnitPrice
{
get { return fUnitPrice; }
set { SetPropertyValue(nameof(UnitPrice), ref fUnitPrice, value); }
}
decimal fUnitPrice;
public int Qty
{
get { return fQty; }
set { SetPropertyValue(nameof(Qty), ref fQty, value); }
}
int fQty;
public decimal Discount
{
get { return fDiscount; }
set { SetPropertyValue(nameof(Discount), ref fDiscount, value); }
}
decimal fDiscount;
[PersistentAlias("UnitPrice*Qty*(1-Discount)")]
public decimal ExtendedPrice
{
get { return Convert.ToDecimal(EvaluateAlias(nameof(ExtendedPrice))); }
}