It seems like searching with CAML and SPQuery doesn't work properly against custom metadata, when searching for SPFolders instead of files, or when searching for custom content types. I've been using U2U to test a variety of queries, and just not getting anywhere. The doc's aren't very complete on the topic, and google isn't helping either.
In one test, I'm trying to locate any SPFolders in the tree that are a specific custom content-type. If I understand CAML correctly, this should work:
<Query>
<Where>
<Eq>
<FieldRef Name='ContentType' />
<Value Type='Text'>CustomTypeName</Value>
</Eq>
</Where>
</Query>
In another test, I'm trying to locate any SPFolder that has a custom metadata property set to a specific value.
<Query>
<Where>
<Eq>
<FieldRef Name='CustomProp' />
<Value Type='Text'>SpecificPropValue</Value>
</Eq>
</Where>
</Query>
In both cases, I'm setting the root for the search to a document library that contains folders, which contain folders, which contain folders (phew.) Also, I'm setting the SPQuery to search recursively.
The folder I'm searching for a two steps down are the farthest down in the tree. I don't want to iterate all the way in to manually locate the folders in question.
EDIT It might also be helpful to know that I'm using both SPList.GetItems with an SPQuery as an argument, and SPWeb.GetSiteData with an SPSiteDataQuery as an argument. At the moment it appears that folders aren't included in the search-set for either of these queries.
Any help would be greatly appreciated.