2011-10-24 113 views
0

由於數據量巨大,我們的SL4應用程序由於速度變慢而遇到問題。爲了解決這個問題,我們決定做分頁和排序serverside。Silverlight 4服務器端動態分類和分頁WCF RIA

數據庫結構:

  • 客戶表是(的customerID,CustomerLabel,PERSONID)
  • Person表是(PERSONID,名字)
  • 數據網格具有(CustomerLabel,名字)

服務器端的分頁一切正常,同時嘗試分類,我可以使用以下方式輕鬆地對「CustomerLabel」進行分類:

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); 
} 

問題: while propertyName是「Person.FirstName」in datagrid。 「propertyInfo」爲空。

我希望有人能幫助我解決這個問題。

+1

我不明白第一行代碼是如何編譯的。 – Amy

回答