Created
November 3, 2012 16:43
-
-
Save vman/4007867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SPSiteDataQuery query = new SPSiteDataQuery(); | |
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 only the Tasks List in each web. | |
query.Lists = "<Lists ServerTemplate=\"107\" MaxListLimit=\"0\"/>"; | |
/*Specifying the MaxListsLimit as 0 means that there is no limit on how many lists | |
in the site collection will be queries. If you want you can limit this number to | |
increase your performance.*/ | |
query.Webs = "<Webs Scope=\"Recursive\" />"; | |
//Specifying the row limit will limit the number of items which will be returned. | |
//query.RowLimit = 100; | |
DataTable results = SPContext.Current.Web.GetSiteData(query); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment