Silverlight 4.0 silverlight 4中使用WCF RIA的服务器端动态排序和分页
由于数据量巨大,我们的SL4应用程序遇到了速度变慢的问题。为了解决这个问题,我们决定在服务器端进行分页和排序 数据库结构:Silverlight 4.0 silverlight 4中使用WCF RIA的服务器端动态排序和分页,silverlight-4.0,wcf-ria-services,Silverlight 4.0,Wcf Ria Services,由于数据量巨大,我们的SL4应用程序遇到了速度变慢的问题。为了解决这个问题,我们决定在服务器端进行分页和排序 数据库结构: 客户表是(customerID、CustomerLabel、personId) Person表是(personId,FirstName) Datagrid具有(CustomerLabel,FirstName) 服务器端的分页运行正常,在尝试排序时,我可以使用以下工具轻松排序“CustomerLabel”: IEnumerable source=this.ObjectCo
- 客户表是(customerID、CustomerLabel、personId)
- Person表是(personId,FirstName)
- Datagrid具有(CustomerLabel,FirstName)
IEnumerable source=this.ObjectContext.Customers.Include(“Person”);
source=source.OrderByDescending(p=>GetKeySelector(p,propertyName));
私有静态对象GetKeySelector(客户p,字符串propertyName)
{
PropertyInfo PropertyInfo=target.GetType().GetProperty(propertyName);
返回propertyInfo.GetValue(target,null);
}
问题:
而propertyName在datagrid中是“Person.FirstName”。“propertyInfo”为空
我希望有人能在这方面帮助我。我不太明白您为什么不使用内置功能。这篇文章涵盖了你想做的事情吗
我不明白第一行代码是如何编译的。
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);
}