How do you specify the source list when doing a CAML query that covers more than one list? Using a tool like U2U CAML Query Tool to write your queries doesn’t specify any field that references the source list.  

To reference the list URL you need to use the FileDirRef field. Here’s some example code which includes logic that strips out the URL from the string that’s returned as it’s a Lookup field type:

query.ViewFields = @”<FieldRef Name=’FileDirRef’ Nullable=’TRUE’ />”;
urlValue = row["FileDirRef"].ToString().Substring(row["FileDirRef"].ToString().IndexOf(“#”) + 1);

Advertisement