Sharepoint client 'List' no extension method 'Items'

Ben Smith 21 Reputation points
2021-07-15T16:00:04.227+00:00

I am using the template from the documentation for How to Update List Items on a Sharepoint List using C#. I am using the input rows from a SQL statement source within SSIS.

I have the Microsoft.Sharepoint.Client reference set up. Here is my code

public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        string siteUrl = "http://MyServer/sites/MySiteCollection";

        ClientContext clientContext = new ClientContext(siteUrl);
        SP.List oList = clientContext.Web.Lists.GetByTitle("Enrollment");

        ListItem oListItem = oList.Items.GetById(Row.ID);

        oListItem["STATUS"] = Row.Status;

        oListItem.Update();

        clientContext.ExecuteQuery();

    }

But I get the error message on the line ListItem oListItem = oList.Items.GetById(Row.ID);

'List' does not contain a definition for 'Items' and no extension method 'Items' accepting a first argument of type 'List' could be found (are you missing a directive or assembly reference?

I have the namespaces set up correctly

using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

What am I missing?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,628 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,453 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,573 questions
0 comments No comments
{count} votes

Accepted answer
  1. sadomovalex 3,626 Reputation points
    2021-07-15T16:55:13.2+00:00

    according to List class members there is no Items property for List class. However there is List.GetItemById method which does what you need - returns list item with specified id. So your code will look like this:

    var oListItem = oList.GetItemById(Row.ID);  
    
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful