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 Please see Release Notes or Changelog 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. For information about generating client code, see Client Code Generation.
To add a computed property
In the client project, add a class file.
Declare a partial class with the same name and namespace as the entity proxy class you want to modify.
Add a property that creates a new value based on one or more values in the entity proxy class.
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.
You can data bind to this computed property with the following code.
Last updated