Binding To Computed Properties With RIA Services Code Sharing

By John at October 03, 2009 23:33
Filed Under: Techy

I question came up over at silverlight.net that I wrote an example for.  The scenario is that we want to bind our RIA Service data context to a DataGrid control via a DomainDataSource.  We also want to have an extra column which computes a value based on other data that exists in each row.

My approach to this scenario is to utilize the code sharing feature of RIA Services to pass across a property which computes the value on client-side.  As you will see, the DataGrid and DomainDataSource accommodate this approach rather nicely.

We’re going to keep things simple on the server-side for this example and not associate our Domain Service to any entities in a database.  So add a new DomainService called “DemoService” but don’t associate it with any data.

Ok now that we have a Domain Service, lets create an entity object to work with in a class file called “Person.cs”:

  1. using System.ComponentModel.DataAnnotations;
  2. namespace RIAServicesSharedCodeExample.Web
  3. {
  4.     public partial class Person
  5.     {
  6.         [Key]
  7.         public string Name { get; set; }
  8.         [Required]
  9.         public int Age { get; set; }
  10.     }
  11. }

 More...

What is myOSity?

myOSity is a On-Demand Operating System that runs in your browser.  You can run applications, work with files, keep in touch and share things with your friends, and more.  The goal of myOSity is to combine the best aspects of operating systems and social networking, while hopefully leaving out all the annoying stuff.

Curious?

To check out myOSity for yourself click here.

Have a game or other Silverlight project that you want to become part of the growing list of applications on myOSity? Contact Me for details.

Join The Team!

Currently looking for other developers interested in being a part of the project.  Contact Me for details or read this post.

About John

I am the founder and lead designer of myOSity.com.  I've been a technologist, in one form or another, for over 20 years.

Protected by Commentor
0 comments approved
4 spam caught
Since December 1, 2008
Powered by Spam Counter