代码之家  ›  专栏  ›  技术社区  ›  Khan

CAML查询查找参数不存在的记录?

  •  0
  • Khan  · 技术社区  · 16 年前

    我有一个sharepoint列表,其中有几个字段。当一个字段在其中一条记录上留空时——当我使用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 具有 x0020

    xmlQuery.Append("           <FieldRef Name=\"Employee_x0020_Title\" />");
    
    2 回复  |  直到 12 年前
        1
  •  1
  •   Kusek    16 年前

    <Where>       
    <IsNull>           
    <FieldRef Name="Name" />       
    </IsNull>   
    </Where>
    
        2
  •  0
  •   zincorp    16 年前

    这是一个很长的列表,但是您的“名称”列在列表中实际命名为“标题”吗?

    FieldRef需要字段AFAIK的内部名称

    推荐文章