使用 SPQuery 或 SPSiteDataQuery 对象查询列表时 CAML GroupBy 的用法
我不确定在查询列表时如何使用 GroupBy 子句。 无论 groupby 子句如何,SPListItemCollection 或数据表看起来都完全相同。
SPQuery query = new SPQuery();
query.Query = "<GroupBy><FieldRef Name=\"Area\"/></GroupBy>";
DataTable result = list.GetItems(query).GetDataTable();
// result.Rows.Count = Same as ungrouped query
GroupBy 仅受 Lists.asmx Web 服务支持吗?
在 MS Social 上找到了一个参考,表明 SPSiteDataQuery 对象不支持它 http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ab8df6f5-35a0-401e-88cb-3eb31362bf0c/
I'm not sure how to use the GroupBy clause when querying a list. The SPListItemCollection or datatable looks exactly the same regardless of the groupby clause.
SPQuery query = new SPQuery();
query.Query = "<GroupBy><FieldRef Name=\"Area\"/></GroupBy>";
DataTable result = list.GetItems(query).GetDataTable();
// result.Rows.Count = Same as ungrouped query
Is GroupBy only supported by Lists.asmx webservice?
Found a reference on MS Social which suggests it's not supported on the SPSiteDataQuery object http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ab8df6f5-35a0-401e-88cb-3eb31362bf0c/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信该子句与分组在用户界面中的显示方式更相关。 就返回的数据而言,您可能/应该进行一些排序,但仅此而已。
关于 UI,有一个 GroupLimit 元素,它限制返回的组数。 还有 Collapse 元素,与 SPQuery 一起使用时没有任何意义。
您希望数据有何不同?
I believe that clause is more related to how the grouping will be displayed in the UI. As far as the data returned goes, you might/should get some sorting but that's about it.
Regarding the UI, there is the GroupLimit element which limits how many groups are returned. There is also the Collapse element which has no meaning when used with SPQuery.
How were you hoping the data would be different?