Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.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# Outlook事件列表的OData不能按“排序”;Id";_C#_Microsoft Graph Api_Outlook Restapi - Fatal编程技术网

C# Outlook事件列表的OData不能按“排序”;Id";

C# Outlook事件列表的OData不能按“排序”;Id";,c#,microsoft-graph-api,outlook-restapi,C#,Microsoft Graph Api,Outlook Restapi,我试图从Microsoft Graph获得以下事件列表 我想按lastModifiedDateTime和id的顺序获取列表 以下是示例查询: var getResource = string.Format("/me/calendar/events/?$filter=lastModifiedDateTime ge {0}&$orderBy=lastModifiedDateTime, id", XmlConvert.ToString(updatedMin, XmlDateTimeSerial

我试图从Microsoft Graph获得以下事件列表

我想按
lastModifiedDateTime
id
的顺序获取列表

以下是示例查询:

var getResource = string.Format("/me/calendar/events/?$filter=lastModifiedDateTime ge {0}&$orderBy=lastModifiedDateTime, id", XmlConvert.ToString(updatedMin, XmlDateTimeSerializationMode.Utc));
但是,当我执行它时,它会导致一个错误:

{
  "error": {
    "code": "ErrorInvalidProperty",
    "message": "The property 'Id' does not support filtering.",
    "innerError": {
      "request-id": "bb56a0d0-46f3-4b7c-80bd-043a0b3fd8b5",
      "date": "2018-09-17T15:23:40"
    }
  }
}
事实上,我没有在
$filter
中设置
Id
,而是将其设置为
$orderby

当我试图从
$orderby
中排除
Id
时,它起作用了。以下是工作查询:

var getResource = string.Format("/me/calendar/events/?$filter=lastModifiedDateTime ge {0}&$orderBy=lastModifiedDateTime", XmlConvert.ToString(updatedMin, XmlDateTimeSerializationMode.Utc));

任何人都知道如何根据
Id
对列表进行排序吗?

您不能根据
Id
进行排序,这样做也没有任何意义。
id
是几个属性(主题、路径等)的散列组合。因此,它们的价值既不是可订购的,也不是人类可读的

例如,这是一个实际的
id
值:

AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OABGAAAAAAAiQ8W967B7TKBjgx9rVEURBwAiIsqMbYjsT5e-T7KzowPTAAAAAAENAAAiIsqMbYjsT5e-T7KzowPTAACNM9xPAAA=
另外,我强烈建议使用,而不是自己滚动。它将有助于缩短学习曲线,并为您提供更可读的代码:

await graphClient.Me
   .Calendar
   .Events
   .Request()
   .Filter("lastModifiedDateTime ge {dateTime}")
   .OrderBy("lastModifiedDateTime") 
   .GetAsync();

由于某些原因,我不得不遵守事件的顺序。因此,按id排序将解决此问题。但是,由于错误的错误通知,我假设按id排序中存在错误。如果不是错误的话。然后,他们至少应该修复错误通知。按
id
排序会与您想要的相反,它会导致几乎随机的顺序。此外,如果编辑了这些事件中的任何一个(即使是对主题的微小更改),顺序也会改变。此外,
/events
端点仅返回单个事件和事件主节点。如果存在重复事件,则仅返回序列中的第一个事件。要获取完整的日历,您需要使用
/calendarView