Back to Devexpress

Create a Calculated Property

expressappframework-404195-getting-started-in-depth-tutorial-blazor-define-data-model-and-set-initial-data-define-data-model-and-set-initial-data-with-ef-core-create-a-calculated-property-ef-core.md

latest1.3 KB
Original Source

Create a Calculated Property

  • Sep 08, 2025
  • 2 minutes to read

This topic explains how to create calculated properties.

The example code below declares a Payment entity class with the following properties:

  • Rate (a persistent property)
  • Hours (a persistent property)
  • Amount (a non-persistent, calculated property: Amount = Rate * Hours)

Note

Before you proceed, take a moment to review the previous lesson:

Step-by-Step Instructions

  1. Navigate to the MySolution.Module\Business Objects folder. Create a Payment class. Replace the auto-generated declaration with the following code:

  2. Register the Payment type in DbContext:

  3. Run the application in debug mode with attached debugger. Select the Payment item in the navigation control and click New. In the Detail View, change the Rate and Hours properties and note the updated Amount value.

Next Lesson

Add a Simple Action