var itemCount = list.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;
And you should be aware of that the suggested way is not always up-to-date, and therefore totaly out of question for me...
ReplyDeleteYou could see the tracing in the by turn on the Dashboard Developer to see how the SharePoint execute the query from database if you get the item count by list.Items.Count. That's no best practice.
ReplyDelete