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:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?