gpt4 book ai didi

c# - SharePoint GetListItems - 获取所有列,按集列表 ID 过滤。 C#

转载 作者:行者123 更新时间:2023-11-30 14:40:17 24 4
gpt4 key购买 nike

在此 WS 消费者 C# 代码中,获取所有列表列(我只看到 10 个可用属性)和过滤一组 ID=3 的最简单方法是什么。我是否必须在 ndViewFields 中对所有这些进行限定?我应该把我的 caml 放在哪里?谢谢。

XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>FALSE</DateInUtc><ExpandUserField>FALSE</ExpandUserField>";
//ndViewFields.InnerXml = "<FieldRef Name='Title' /><FieldRef Name='Title' />"; //you don't need to specifically request the 'ID' column since it will be returned regardless
ndViewFields.InnerXml = "<FieldRef Name='Title' />"; //you don't need to specifically request the 'ID' column since it will be returned regardless
ndQuery.InnerXml = "<OrderBy><FieldRef Name='Title'/></OrderBy>";

try
{
XmlNode ndListItems = wList.GetListItems("MyList", string.Empty, ndQuery, ndViewFields,null, ndQueryOptions, null);

foreach (XmlNode node in ndListItems)
{
if (node.Name == "rs:data")
{

for (int f = 0; f < node.ChildNodes.Count; f++)

{
if (node.ChildNodes[f].Name == "z:row")
{
//Add the employee ID to my 'employeeIDs' ArrayList
Titles.Add(node.ChildNodes[f].Attributes["ows_Title"].Value);

最佳答案

你的 ndQuery 应该包含:

<Query>
<Where>
<Eq>
<FieldRef Name="ID" />
<Value Type="Counter">3</Value>
</Eq>
</Where>
</Query>

和 ndViewFields 应该包含:

<ViewFields>
<FieldRef Name="ID" />
<FieldRef Name="Title" />
... all other fields you need
</ViewFields>

关于c# - SharePoint GetListItems - 获取所有列,按集列表 ID 过滤。 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5583964/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com