Google+

SPList.GetItemById() and SPList.Items.GetItemById()

Leave a comment

September 21, 2016 by Ruaan Harmzen

When using code to access a specific item in a SharePoint list there is a big difference between the following 2 lines of code:
SPList.GetItemById()
SPList.Items.GetItemById()

The first line is the correct one to use and will perform the best (and as expected when query an ID)
The second line will load ALL the items in the list first and THEN only select the correct item which will cause slow performance and timeouts when your list gets bigger

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: