Reputation: 21
I'm unable to find a good example of reading sharepoint listitems and filtering on a custom column with the PNP.Core sdk library in C#.
I could filter on Title:
var listItems = await pnpContext.Web.Lists.GetByTitle("TestList")
.Items
.Where(x => x.Title == "Foo" )
.ToListAsync();
But I would need something like this:
var listItems = await pnpContext.Web.Lists.GetByTitle("TestList")
.Items
.Where(x => x["Status"] == "Completed" )
.ToListAsync();
The result api call should look like this (or the corresponding graph api call):
_api/web/lists/getByTitle('TestList')/items/?$filter=Status eq 'Completed'
Upvotes: 0
Views: 670
Reputation: 141
I checked the documentation, https://pnp.github.io/pnpcore/using-the-sdk/listitems-intro.html Maybe you can do this
var listItems = await context.Web.Lists.GetByTitle("TestList")
.Items
.Where(x => x.Values["Status"].ToString() == "Completed")
.LoadAsync();
Upvotes: 1