Search code examples
c#asp.net-coremicrosoft-graph-api.net-6.0

Microsoft.Graph.QueryOption type is missing


I have .NET 6 console application and installed two Nuget packages

  • Azure.Identity (1.9)
  • Microsoft.Graph (5.12)

however following code does not work

enter image description here

the Microsoft.Graph.QueryOption type could not be found, but it should be available in the Microsoft.Graph package based on following documentation

https://learn.microsoft.com/en-us/dotnet/api/microsoft.graph.queryoption?view=graph-core-dotnet

enter image description here

any idea?


Solution

  • you might downgrade your graph package to v4.x.

    enter image description here

    That's because in V5.x SDK, QueryOption class is no longer used.

    To pass query Options, the QueryOption class is no longer used. Query options are set using the requestConfiguration modifier as follows

    var user = await graphServiceClient
        .Users["{user-id}"]
        .GetAsync(requestConfiguration => requestConfiguration.QueryParameters.Select = new string[] { "id", "createdDateTime"});
    

    enter image description here