Skip to content

Instantly share code, notes, and snippets.

@vman
Created November 3, 2012 17:17
Show Gist options
  • Save vman/4008000 to your computer and use it in GitHub Desktop.
Save vman/4008000 to your computer and use it in GitHub Desktop.
CrossListQueryInfo query = new CrossListQueryInfo();
query.ViewFields = "<FieldRef Name=\"Title\" /><FieldRef Name=\"DueDate\" />";
query.Query = @"<Where>
<And>
<Eq>
<FieldRef Name='AssignedTo'/>
<Value Type='User'>" +
SPContext.Current.Web.CurrentUser.Name
+ @"</Value>
</Eq>
<Neq>
<FieldRef Name='Status'/>
<Value Type='Choice'>Completed</Value>
</Neq>
</And>
</Where>";
query.Lists = "<Lists ServerTemplate=\"107\" MaxListLimit=\"0\"/>"; //Tasks Lists
query.Webs = "<Webs Scope=\"Recursive\" />";
//query.RowLimit = 100;
//Make sure to set this property as true.
query.UseCache = true;
CrossListQueryCache cache = new CrossListQueryCache(query);
//Make sure to use one of the overloads of the GetSiteData method which takes in the SPSite parameter
//and not the SPWeb parametre.
DataTable results = cache.GetSiteData(SPContext.Current.Site);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment