So I was challenged today to leverage the SPSiteDataQuery class to access list data that spans multiple lists/sites instead of just enumerating all of those sites and lists and then using a standard SPQuery against each list.

First off, it’s worth noting that I could not just use examples in this link->, because I don’t have my list templates complete yet… I would have just turned up every document library across all of these sites – ick

So, my buddy Joel checks in with me and tosses me a link to CAML.NET pictured here, so instead of guessing at the attributes of the query I was building in my c# string, I could have intellisense

Once installed, that intellisense had no connection to my c# string, so I dug through the CAML for common Visual Studio / SharePoint artifacts that can be leveraged to avoid memorizing/creating specific schema files myself every time.  I’m sure there are several items out there that will satisfy this, but this is what I had laying around:


For SPSiteDataQuery
– In your test project, create a new Site Definition
– Open up the onet.xml file and look for the <Lists /> node
– Fix that node to contain a <List node and viola, intellisense give you your options
– I turn a little red because I probably could have guessed that there could be a "Title” attribute, after all, this is SharePoint


For SPQuery
– Create/use a list definition
– Schema.xml within has a <List><MetaData><Views><View><Query… viola!


Coming up in Part 2:  U2U CAML for SPQuery building….