Difference between SPList.ItemCount and SPList.Items.Count

Many times we encounter difficulties to choose between SPList.ItemCount and SPList.Items.Count while querying the share point list.

So after reading this blog,you will be in better position to choose between SPList.ItemCount and SPList.Items.Count 😉

SPList.ItemCount: If you want to get the count of list items including folder and sub folder,use SPList.ItemCount property of the list.

SPList.Items.Count: The SPLISt.Items property returns all the files in a document library/List, including files in sub folders, but not the folders themselves.SPList.Items returns the list items by running a query with Scope=Recursive ViewAttribute.Hence if you want to get only the count of items then use SPList.Items.Count

Permission:As SharePoint provide item level permission,to use SPList.Items.Count code must be running with the full permission else it will result into access denied. SPList.ItemCount not required as such permission.

Performance:Performance wise  SPList.ItemCount  is faster as it is static property of SPList. SPList.Items is slower as it has to  first get the data then do the counting.

However SPList.ItemCount occasionally return unexpected results.so It is best practice is to use one of the GetItem* methods of SPList to return a filtered collection of items.


2 thoughts on “Difference between SPList.ItemCount and SPList.Items.Count

  1. Hi RajendraPratap

    Do you do custom dev work? We need a Generic Sharepoint Event receiver built for our application.

    Please let me know if you are interested.



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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s