item.Recycle returns 一个空的 GUID(SharePoint Online,C#)

item.Recycle returns an empty GUID (SharePoint Online, C#)

所以,长话短说,我想删除(回收)一个项目,保存它的 ID,然后使用该 ID 从垃圾桶中恢复它。

我可以通过名称从垃圾桶中恢复项目,如下所示:

if (rItem.leafname == "torecycle.docx")
    {
        rItem.restore();
        client.executequery();
    }
}

但这需要用户事先知道项目的名称。

当一个项目被回收并移到垃圾箱时,它的 ID 会发生变化。 item.Recycle() 方法应该 return 一个 ClientResult<Guid>RecycleBinItem 的新 Id,但是 returned Guid 是空的(所有零)。

我这样回收物品:

if (item.DisplayName == "torecycle")
{
    client.Load(item);

    var recycledItem = item.Recycle(); 
    var newGuid = recycledItem.Value;

    Console.WriteLine("new guid " + newGuid);

    Client.ExecuteQuery();
}              

打印出来的是 new guid 00000000-0000-0000-0000-000000000000,但它确实将回收站项目正确地移到了垃圾箱。

我是不是漏掉了什么?如何获得 RecycleBinItem 的实际 Guid?

如有任何帮助,我们将不胜感激!

Recycle 函数的 return 值是一个 ClientResult<T>,它只是底层 SOAP request/response 模型的包装器。请求在本地收集并在调用 ExecuteQuery 时发送。因此结果值只会在该调用完成后填充。

要了解 SharePoint 服务器和客户端对象模型之间的差异,有必要查看 overall concept, because in the documentation of ClientResult,但从未提及。