Friday, December 21, 2012

SharePoint 2010 - Recursive Query in List/Library

CAML query is by default non recursive. If you execute a CAML query, you will end up with items from the list root folder.

You have to define extra query options as shown below in case you want to query all folders and sub folders within a list (Recursive Query) :

query.ViewAttributes = "Scope='Recursive'";