Custom calculated properties

To make a custom calculated property, you need to inherit from the type Telerik.Sitefinity.Web.Services.Extensibility.CalculatedProperty. This is an abstract class and implements the following mandatory methods:

  • ReturnType
    The ReturnType parameter specified the actual return type of the property. It can be a collection, an object, or a simple type.
    The calculated property has a name value collection of parameters that are used to configure the property.

    NOTE: When specifying the return type, the type must be either registered in the Types available in the service or must be decorated with a DataContract attribute.

  • GetValues
    The GetValues method requires a developer to return the values for each of the entry in the IEnumerable collection. This collection holds all of the queried objects that will be returned to the client. You must return a dictionary with a reference to the object as key of that dictionary and a value for that object. 

Sitefinity has one OOB CalculatedProperties: MediaUrlCalculatedProperty.
The MediaUrlCalculatedProperty can be configured with the following parameters – absolute and thumbnail. This specifies whether to generate an absolute URL for the property and the type of the thumbnail to return respectively.

The following example is a custom calculated property for getting the provider name of an item:

Was this article helpful?