仅获取非重复项的 CAML 查询

CAML Query to get only non duplicates

我的第一个目标是在我的 sharepoint list 中获取状态为 'Pending' 的所有项目。到目前为止我的代码是这样的:

using (var clientContext = new ClientContext(spSite.Trim()))
            {
                clientContext.Credentials = GetNetworkCredential();
                var approvalLists = clientContext.Web.Lists.GetByTitle(approvalLibraryName);

                CamlQuery query = new CamlQuery();
                query.ViewXml = "<View>" +
                                    "<Query>" +
                                       "<Where>" +
                                           "<Eq>" +
                                               "<FieldRef Name='IsApproved'/><Value Type='Choice'>Pending</Value>" +
                                           "</Eq>" +
                                       "</Where>" +
                                   "</Query>" +
                               "</View>";

                ListItemCollection approvalListItem = approvalLists.GetItems(query);
                clientContext.Load(approvalListItem);
                clientContext.ExecuteQuery();

            }

它正在工作,但我随后意识到可以在该列表中插入超过 1 个特定项目。因此,例如对于项目 request_100,它可以有一行用于 pending,另一行用于 approved。所以我只需要获取那些状态为 'Pending' 的非重复项目。是否可以让 group by then 只获取 count = 1 的那些人?因为我在想是否可以只加载所有项目然后使用 linq 列表对其进行操作。或者你们对此有其他建议吗?

我的第一个想法确实也是在 ItemCollection 上使用 linq,它应该工作得很好。

但想想看,如果您 select 只有 'pending' 行,您将不会得到重复项,对吗?或者是否可以有多个项目,例如 'request_100' 状态为 'Pending'?

检查这个与您的问题相似的问题:https://sharepoint.stackexchange.com/questions/43262/how-to-use-groupby-in-caml-query