I am using code like the following to get a list of all documents in a site with SPSiteDataQuery however, it is returning all sorts of documents that were not uploaded by the user. What is the best way to filter the list to only those documents that a user would have uploaded?
I am suspecting that there is a query that I can use but I am not sure what FieldRef I should be using to find only user uploaded documents (not hidden or system type document files).
see * below in the method
thanks
protected DataTable GetListDataSPSiteDataQuery(string siteUrl, bool recursive, ref string error) {
DataTable results = null;
using (SPSite site = new SPSite(siteUrl)) {
SPWeb web = site.OpenWeb();
SPSiteDataQuery query = new SPSiteDataQuery();
//query.Webs = "<Webs Scope='SiteCollection' />"; //query all web sites in site collection
if (recursive)
query.Webs = "<Webs Scope='Recursive' />";
query.Lists = "<Lists ServerTemplate='101' Hidden='FALSE' MaxListsLimit='0' />";
//query.Lists = "<Lists BaseType='1' MaxListsLimit='0' />"; //document library only (0=generic list, 1=doc library,3=discussino forum,4-vote or survey,5=issues list)
// *** can i provide a query here to filter for the documents i am interested in?
query.Query = string.Empty;
//query.Query = "<Where>" +
// "<Gt>" +
// "<FieldRef Name='File_x0020' />" +
// "<Value Type='Number'>0</Value>" +
// "</Gt>" +
// "</Where>";
query.ViewFields = _viewFields;
results = web.GetSiteData(query);
}
return results;
}