如何从sharepoint 2010客户端对象模型中获取更改?

时间:2012-10-10 07:35:56

标签: c# sharepoint-2010 sharepoint-clientobject sharepoint-object-model

以下是代码:

        ClientContext context = new ClientContext("http://SPSite");
        context.Credentials = new NetworkCredential("user", "pwd", "domain");
        ChangeQuery cq = new ChangeQuery(true, true);                  
        ChangeCollection col = list.GetChanges(cq);            
        context.Load(col);
        context.ExecuteQuery();
        MessageBox.Show(col.Count.ToString());

无论所做的更改如何,它始终显示为0。

1 个答案:

答案 0 :(得分:2)

ClientContext context = new ClientContext("http://SPSite");
context.Credentials = new NetworkCredential("user", "pwd", "domain");
ChangeQuery cq = new ChangeQuery(true, true); 
cq.ChangeTokenStart = new ChangeToken();
cq.ChangeTokenStart.StringValue = "1;3;" + list.Id.ToString() + ";" + DateTime.UtcNow.AddHours(-1).Ticks.ToString() + ";-1";                 
ChangeCollection col = list.GetChanges(cq);            
context.Load(col);
context.ExecuteQuery();
MessageBox.Show(col.Count.ToString());

即使我不喜欢自己创建令牌,但这似乎是迄今为止我用谷歌搜索工作的唯一方式。