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
Getting such a property to show up in the UI is tricky since the calculation is located in the typed C# model, and the UI operates on a generic database model. Also, adding support for calculated properties in the properties would always come with a lot of constraints as only calculations the CMS are aware of could be handled, and you might need to use data from a third-party service to complete it.
I have reached out to engineering regarding your question about Graph/S&N indexing.