# How to: Add Computed Properties on the Client

\[ **This document was written for WCF Services Version 1 Service Pack 2 and might not be up to date** \
&#x20;Please see [Release Notes](https://github.com/OpenRIAServices/OpenRiaServices/releases) or [Changelog](https://github.com/OpenRIAServices/OpenRiaServices/blob/main/Changelog.md) for a list of changes since WCF RIA Services ]

You can add properties in the Open Ria Services client project that are computed from properties in the entity class. Partial methods are used to raise the event that notifies UI elements that the value has changed. When you add computed properties, the property only exists in the client project. This topic describes how to add such computed properties.

For more information about customizing generated code, see [Customizing Generated Code](https://openriaservices.gitbook.io/openriaservices/ee707349/ee707345). For information about generating client code, see [Client Code Generation](https://openriaservices.gitbook.io/openriaservices/ee707349/ee707359).

## To add a computed property

1. In the client project, add a class file.
2. Declare a partial class with the same name and namespace as the entity proxy class you want to modify.
3. Add a property that creates a new value based on one or more values in the entity proxy class.
4. Implement the On\[CustomProperty]Changed partial method for each property used in computing the new value and call the `RaisePropertyChanged` method to notify the framework that the computed property has changed.

   The following example shows how to calculate the total available time away from work for an employee based on vacation hours and sick leave. A change to either vacation hours or sick leave hours will produce a change in total off hours.

   ```
   Imports OpenRiaServices.Client

   Namespace Web
     Partial Public Class Employee
       Inherits Entity

       ReadOnly Property TotalOffHours() As Integer
         Get
           Return Me.SickLeaveHours + Me.VacationHours
         End Get
       End Property

       Private Sub OnSickLeaveHoursChanged()
         Me.RaisePropertyChanged("TotalOffHours")
       End Sub

       Private Sub OnVacationHoursChanged()
         Me.RaisePropertyChanged("TotalOffHours")
       End Sub
     End Class
   End Namespace
   ```

   ```csharp
   using OpenRiaServices.Client;

   namespace RIAServicesExample.Web
   {
     public partial class Employee : Entity
     { 
       public int TotalOffHours 
       { 
         get { return this.SickLeaveHours + this.VacationHours; } 
       } 
       partial void OnSickLeaveHoursChanged() 
       { 
         this.RaisePropertyChanged("TotalOffHours"); 
       } 
       partial void OnVacationHoursChanged() 
       { 
         this.RaisePropertyChanged("TotalOffHours"); 
       } 
     }
   }
   ```

   You can data bind to this computed property with the following code.

   ```
   <dataForm:DataField Label="Total Off Hours"> 
     <TextBox Text="{Binding TotalOffHours, Mode=OneWay}" />
   </dataForm:DataField>
   ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openriaservices.gitbook.io/openriaservices/ee707349/ee707345/ee707331.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
