Computed readonly field for a content type
A way to define a property or a method within a given content type having the following characteristics:
- It is a computed property: the value will be determined by querying other related database tables
- The property will be displayed as read-only / disabled on the Optimizely dashboard / edit content type
The next approach does not display the property in Optimizely Admin UI
[Display(
Name = "Total Price",
Order = 130,
GroupName = GroupNames.Plm)]
public virtual decimal TotalPrice => Items?.Sum(i => i.Quantity * i.UnitPrice) ?? 0;
This happened because it looks like content graph, SearchText, and GetSearchableProperties() in Search and Navigation all get the value for a property as stored in the database, and do not engage the getter on the class.
Thanks
5
votes
