Search code examples
c#linqasp.net-coresharepointmicrosoft-graph-api

Syntax of Linq Query with Filter in Microsoft Graph API


Trying to filter my Linq Query so that I only receive the Items with a certain mail address. What would be the correct syntax for Filter?

The 'Mail' column in my SharePoint List is a single line of text (not an actual person field/column).

I think the documentation for this (especially LINQ) is very poor.

 Items = await MyGraphClient.graph.Sites["xxxxxxxxxxxxxxxxxxxxxxxxx"]
     .Lists["xxxxxxxxxxxxxxxxxx"]
     .Items
     .Request()
     .Expand("fields($select=ID,Status,Mail,Datum)")
     .Filter("fields($select=Mail) eq 'test@xxxxxxxx.de'")
     .GetAsync();

The error I get: Could not find a property named 'Mail' on type 'microsoft.graph.listItem'

The rest of the Query works as expected.

Thank you in advance.


Solution

  • It's working now with

    .Expand("fields($select=TicketID,Status,Mail,Datum)").Filter("fields/Mail eq 'test@xxxxxxxxxxx.de'")

    BUT you have to add 'Mail' as an indexed column in SharePoint. Thank you everyone!