图 API 查询 - 如何结合展开和 select
Graph API query - how to combine expand and select
我有以下工作代码,它列出了 Sharepoint 站点中的所有文件并获取了它们的 driveItem 详细信息:
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request()
.Expand(item => item.DriveItem)
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
现在除了上述查询已经获取的数据之外,我还需要一种方法来获取每个项目的发布状态。我在 Whosebug 上找到了这个 post:
所以我尝试将我的代码更改为如下所示:
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request()
.Expand(item => item.DriveItem)
.Select(item => item.DriveItem.Publication)
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
但我收到以下错误消息:
Message=Anonymous type in lambda expression may only be initialized
with direct members of type ListItem Parameter name: selectExpression
Source=Microsoft.Graph
编辑 1
我也试过这个:
var queryOptions = new List<QueryOption>()
{
new QueryOption("select", "publication")
};
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request(queryOptions)
.Expand(item => item.DriveItem)
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
但我得到的错误是:
Inner Exception 1: JsonReaderException: '{' is invalid after a value.
Expected either ',', '}', or ']'. LineNumber: 0 | BytePositionInLine:
223.
这对我有用。在 Expand
中,我指定了要使用 select
语句扩展的 属性,该语句在 driveItem
中指定了 属性
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request()
.Expand("driveItem($select=publication)")
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
我有以下工作代码,它列出了 Sharepoint 站点中的所有文件并获取了它们的 driveItem 详细信息:
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request()
.Expand(item => item.DriveItem)
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
现在除了上述查询已经获取的数据之外,我还需要一种方法来获取每个项目的发布状态。我在 Whosebug 上找到了这个 post:
所以我尝试将我的代码更改为如下所示:
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request()
.Expand(item => item.DriveItem)
.Select(item => item.DriveItem.Publication)
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
但我收到以下错误消息:
Message=Anonymous type in lambda expression may only be initialized with direct members of type ListItem Parameter name: selectExpression Source=Microsoft.Graph
编辑 1
我也试过这个:
var queryOptions = new List<QueryOption>()
{
new QueryOption("select", "publication")
};
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request(queryOptions)
.Expand(item => item.DriveItem)
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();
但我得到的错误是:
Inner Exception 1: JsonReaderException: '{' is invalid after a value. Expected either ',', '}', or ']'. LineNumber: 0 | BytePositionInLine: 223.
这对我有用。在 Expand
中,我指定了要使用 select
语句扩展的 属性,该语句在 driveItem
var directoryContents = await App.GraphClient.Sites[SiteIdShortName].Lists[sharedDocsDriveId]
.Items
.Request()
.Expand("driveItem($select=publication)")
.GetAsync();
SharedDocumentList.ItemsSource = directoryContents.CurrentPage.ToList();