Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用CAML查询检查ContentType.Hidden?_C#_Sharepoint_Caml - Fatal编程技术网

C# 如何使用CAML查询检查ContentType.Hidden?

C# 如何使用CAML查询检查ContentType.Hidden?,c#,sharepoint,caml,C#,Sharepoint,Caml,我想从CAML查询筛选到ListItem.ContentType.Hidden 与SharePoint到Linq类似的代码 var query = from item in list.GetItems(CamlQuery.CreateAllItemsQuery()) where item.ContentType.Hidden == false select item; 如果我使用纯CAML查询进行检查,我应该编写代码吗?如何编写 这是一个简单的问题 谢谢。您无

我想从CAML查询筛选到ListItem.ContentType.Hidden

与SharePoint到Linq类似的代码

var query = from item in list.GetItems(CamlQuery.CreateAllItemsQuery()) 
                where item.ContentType.Hidden == false select item;
如果我使用纯CAML查询进行检查,我应该编写代码吗?如何编写

这是一个简单的问题


谢谢。

您无法在纯CAML查询中检查
隐藏属性。在CAML中,只有ContentType的名称和ID可用(字段ContentType和ContentTypeID)

如果只有少数隐藏内容类型必须排除,则可以首先加载这些隐藏内容类型并在CAML查询中排除它们:

<Where>
  <And>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[HiddenContentTypeId]</Value>
    </Neq>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[AnotherHiddenContentTypeId]</Value>
    </Neq>
  </And>
  <!-- more hidden content types -->
</Where>
提取隐藏内容类型:

SPWeb web = // ...
IEnumerable<string> contentTypeIds = web.AvailableContentTypes
  .Cast<SPContentType>()
  .Where(ct => ct.Hidden)
  .Select(ct => ct.Id.ToString());
SPWeb=/。。。
IEnumerable ContentTypeId=web.AvailableContentTypes
.Cast()
.Where(ct=>ct.Hidden)
.Select(ct=>ct.Id.ToString());
CAML查询:

<Where>
  <And>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[HiddenContentTypeId]</Value>
    </Neq>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[AnotherHiddenContentTypeId]</Value>
    </Neq>
  </And>
  <!-- more hidden content types -->
</Where>

[HiddenContentTypeId]
[另一个隐藏的内容类型ID]

您无法在纯CAML查询中检查
隐藏的属性。在CAML中,只有ContentType的名称和ID可用(字段ContentType和ContentTypeID)

如果只有少数隐藏内容类型必须排除,则可以首先加载这些隐藏内容类型并在CAML查询中排除它们:

<Where>
  <And>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[HiddenContentTypeId]</Value>
    </Neq>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[AnotherHiddenContentTypeId]</Value>
    </Neq>
  </And>
  <!-- more hidden content types -->
</Where>
提取隐藏内容类型:

SPWeb web = // ...
IEnumerable<string> contentTypeIds = web.AvailableContentTypes
  .Cast<SPContentType>()
  .Where(ct => ct.Hidden)
  .Select(ct => ct.Id.ToString());
SPWeb=/。。。
IEnumerable ContentTypeId=web.AvailableContentTypes
.Cast()
.Where(ct=>ct.Hidden)
.Select(ct=>ct.Id.ToString());
CAML查询:

<Where>
  <And>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[HiddenContentTypeId]</Value>
    </Neq>
    <Neq>
      <FieldRef Name='ContentTypeID'/>
      <Value Type='Text'>[AnotherHiddenContentTypeId]</Value>
    </Neq>
  </And>
  <!-- more hidden content types -->
</Where>

[HiddenContentTypeId]
[另一个隐藏的内容类型ID]

你好,斯特凡先生。你的解释对我来说既简单又直截了当。多亏了你的建议。嗨,斯特凡先生。你的解释对我来说既简单又直截了当。多亏了你的忠告。