我有一个包含多个字段的共享点列表。似乎当其中一条记录上的字段留空时 - 当我使用 CAML 查询查询列表时,该字段上缺少该属性。
是否可以编写查询以返回不包含此属性的记录?
例子:
id Employee Title description
-------------------------
1 Jeff Person1
2 Bob Person2
3 Charles Person3
4 Person4
5 Person5
有没有办法查询这个只返回 id 为 4 和 5 的记录,因为它们将名称字段留空?
我尝试了以下方法:
System.Text.StringBuilder xmlQuery = new StringBuilder();
xmlQuery.Append("<Query>");
xmlQuery.Append(" <Where>");
xmlQuery.Append(" <IsNull>");
xmlQuery.Append(" <FieldRef Name=\"Employee Title\" />");
xmlQuery.Append(" </IsNull>"); xmlQuery.Append(" </Where>");
xmlQuery.Append("</Query>"); XmlNode query = new XmlDocument();
query.InnerXml = xmlQuery.ToString();
但是这些记录中当然不存在该属性,因此不会返回任何内容
提前致谢!
编辑
在替换Name
with中的任何空格后查询有效x0020
xmlQuery.Append(" <FieldRef Name=\"Employee_x0020_Title\" />");