JayData.org

JayStack OData V4 Server – computed properties

Author: Viktor Lazar February 9th, 2017

, ,


With the latest version of the JayStack OData V4 Server library, you can even more easily create computed properties on your entity models as before. If you are not yet familiar with the basic concepts of the odata-v4-server module, consider reading a comprehensive tutorial here.

Entity model declaration

In this tutorial, we will use this simple Person entity type to show you how to use computed properties.

 

Creating real computed properties

To create computed properties on OData entity or complex types, we will use simple property getters and annotate them with an Edm type decorator. We extend our former example entity model like this:

Please notice, that we added the FullName property getter to the Person class. Inside the getter function, this will be your result entity instance. We will see the computed property in the service metadata and if we implement a controller using the Person entity type, we can see it in the result too.

The Edm.Computed property decorator is only used for annotational purpose. In the metadata, the property will be annotated properly as the OData v4 standard with an Annotation element.

You can see the full working example here.


, ,