Saturday, July 3, 2010

SPContext. What Is It? (More Complex Example)

Perform a query on the current site for cases where item IDs are greater than 100.

SPSiteDataQuery oSiteQuery = new SPSiteDataQuery();

oSiteQuery.Query = "<Where>" +
                                " <Gt>" +
                                " <FieldRef Name="ID" />" +
                                " <Value Type = "Number"> 100 </Value>" +
                                " </Gt>" +
                               "</Where>";

oSiteQuery.ViewFields = "<FieldRef Name="Title" />"

DataTable oQueryResults = SPContext.Current.Web.GetSiteData(oSiteQuery);
oQueryResults.TableName = "queryTable";
oQueryResults.WriteXML("C:\queryTable.xml");

No comments: