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”:
- using System.ComponentModel.DataAnnotations;
- namespace RIAServicesSharedCodeExample.Web
- {
- public partial class Person
- {
- [Key]
- public string Name { get; set; }
- [Required]
- public int Age { get; set; }
- }
- }
More...