Scenario:
You need to query cross-list items across multiple Web sites
Solution:
'SPSiteDataQuery' is more efficent for such a situation.
'SPQuery' should be used to query a particular list
Sample Code:
- SPWeb webSite = SPContext.Current.Web;
- SPSiteDataQuery query = new SPSiteDataQuery();
- query.Lists = "
" ; - query.Query = "
+" - "
Completed "; - System.Data.DataTable items = webSite.GetSiteData(query);
- foreach (System.Data.DataRow item in items)
- {
- Response.Write(SPEncode.HtmlEncode(item["Title"].ToString()) + "
"); - }
No comments:
Post a Comment