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

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

Leave a Reply

Your email address will not be published. Required fields are marked *