Silverlight 4 中使用 WCF RIA 的服务器端动态排序和分页
由于数据量巨大,我们的 SL4 应用程序遇到速度变慢的问题。为了解决这个问题,我们决定在服务器端进行分页和排序。
数据库结构:
- 客户表是(customerID,CustomerLabel,personId)
- 人员表是(personId,FirstName)
- Datagrid有(CustomerLabel,FirstName)
服务器端的分页一切正常,在尝试排序时,我可以轻松排序“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);
}
问题: 而数据网格中的 propertyName 是“Person.FirstName”。 “propertyInfo”为空。
我希望有人能在这方面帮助我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否理解您为什么不使用内置功能。这篇文章涵盖了您想做的事情吗?
WCF RIA 服务 DomainCollectionView< /a>
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