SharePoint Tips: List.ItemCount vs List.Items.Count
If you need to know the total items in the list, how do you write code? The usual way to write code is shown below:
var itemCount = list.Items.Count;
Code Snippet 1: Usual (not suggested) way to get items count
However this will fetch all the records from database and apply the count in memory.
SharePoint object model provides an easiest way to find the items count without fetching all records and you can use the following code snippet to do so:
var itemCount = list.ItemCount;
Code Snippet 2: Suggested way to get items count
Posted by Sohel Rana at 7:13 PM 1 comments
Labels: SharePoint, SharePoint 2010, SharePoint Tips
Technical Solutions Professional | Modern Workplace Architect Lead | Microsoft 365 | SharePoint | Power Platform | MS Teams | React
Leave a Reply