Search code examples
silverlight-4.0wcf-ria-services

Server side dynamic sorting and paging in silverlight 4 with WCF RIA


Due to huge volume of data, our SL4 application encounter problem by getting slower. To solve that we decide to do paging and sorting serverside.

Database structure:

  • Customer table is(customerID, CustomerLabel, personId)
  • Person table is(personId, FirstName)
  • Datagrid has (CustomerLabel, FirstName)

The paging at server side went all ok, while trying for sorting, I can sort easily for "CustomerLabel" using:

IEnumerable<Customer> source = this.ObjectContext.Customers.Include("Person"); 

 source = source.OrderByDescending<Customer, object>(p => GetKeySelector(p, propertyName));

private static object GetKeySelector(Customer p, string propertyName)
{
    PropertyInfo propertyInfo = target.GetType().GetProperty(propertyName);
    return propertyInfo.GetValue(target, null);
}

Problem: while propertyName is "Person.FirstName" in datagrid. The "propertyInfo " is null.

I wish if someone could help me on this.


Solution

  • I'm not sure I understand why you aren't using the built-in functionality. Does this post cover the kinds of things you want to do?

    WCF RIA Services DomainCollectionView