SPList.ItemCount:
SPList.Items.Count:
- If you want to get the count of list items including folder and sub folder,use SPList.ItemCount property of the list.
- Performance wise SPList.ItemCount is faster as it is static property of SPList.
- SPList.ItemCount not required as such permission.
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
- 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.Items is slower as it has to first get the data then do the counting.
No comments:
Post a Comment