JL.*_*JL. 0 c# sharepoint web-services
由于Microsoft没有包含在sharepoint中具有唯一约束的方法,因此必须手动完成.
我通过Web服务方法将项目插入到sharepoint列表中.
如何检查现有列表项是否已存在且具有相同的字段ID值?
我已经知道我应该使用wsLists.getListitems web服务方法,但它并不完全"用户友好".MSDN文档在解释什么应该是一件容易的事情方面再也不是很好.
private bool itemDoesntExist()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"ID\" /><Value Type=\"Text\">" + this.ID + "</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
XmlNode items = this.wsLists.GetListItems(this.ListName , string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, null);
if (items.ChildNodes[1].Attributes["ItemCount"].Value == "0")
{
return true;
}
else
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4419 次 |
| 最近记录: |