Use SPSiteDataQuery to fetch the data from multiple custom lists.
Code Examples are given below:
Retrieve data from Multiple Lists;
SPSiteDataQuery query = new SPSiteDataQuery();
query.Lists = "<Lists ServerTemplate=\"105\" />";
query.Query = "<Where><Gt><FieldRef Name='colname'/>" +
"<Value Type='datatype'>somevalue</Value></Gt>
</Where>";
DataTable dataTable = web.GetSiteData(query);
Fetch data from specific Lists;
string strListIDs += "<Lists>";
strListIDs += "<List ID='GUID'/>";
ListIDs += "<List ID='GUID'/>";
strListIDs += "</Lists>";
query.Lists = strListIDs ;
query.ViewFields = "<FieldRef Name ='Title' />";
DataTable dataTable = web.GetSiteData(query);
No comments:
Post a Comment