Writing CAML-Queries is still no fun. Even with SharePoint 2010… So you often need to test your queries before they actually work.
In case you quickly want to test if your SPSiteDataQuery is correct you can use powershell to “debug” it. Just create an instance of the site-collection and target the root-web with your query-instance.
$site = Get-SPSite -Identity http://my-site-collection $q = New-Object -typeName Microsoft.SharePoint.SPSiteDataQuery $q.Query = "<Where><And><Eq><FieldRef Name='ContentType'/><Value Type='Text'>MyCT</Value></Eq><BeginsWith><FieldRef Name='Url'/><Value Type='URL'>/path</Value></BeginsWith></And></Where>" $q.ViewFields = "<FieldRef Name='ID'/><FieldRef Name='ContentType'/>" $q.Webs = "<Webs Scope='SiteCollection' />" $site.RootWeb.GetSiteData($q) |
This is way faster than doing it in VS…