我有一段代码,可以从SPO列表中提取项目。我应该如何编写foreach / select类型才能读取item.Title f.e?
试图将var项目键入多种类型,但无法获得正确的结果...
var items = await graphServiceClient.Sites["yourtenant.sharepoint.com:/sites/ITOddeleni:"].Lists["TeamsRequest"].Items
.Request(queryOptions)
.GetAsync();
foreach (var item in items)
{
Console.WriteLine(item);
}
我希望它会写出带有项目标题的字符串。 我现在得到的是2x Microsoft.Graph.ListItem(因为列表中有2个项目)
答案 0 :(得分:0)
var queryOptions = new List<QueryOption>()
{
new QueryOption("expand", "fields(select=id,Title)")
};
var items = await graphServiceClient.Sites["yourtenant.sharepoint.com"].Lists["TeamsRequest"].Items
.Request(queryOptions)
.GetAsync();
foreach (var item in items)
{
Console.WriteLine(item.Fields.AdditionalData["Title"]);
Console.WriteLine("Name:" + item.Name);
Console.WriteLine($"ID: {item.Id}");
}
item.Fields.AdditionalData完成该操作。感谢您的建议:-)