Wednesday, August 19, 2009

Used in WSS 3.0

Avoid enumerating through the SPListItemCollection object as each step will invoke a sparate call to a content database.
Code Snippet:
string siteURL="http://chem.agilent.com";
using (SPSite site=new SPSite(siteURL);
{
using(SPWeb web=site.OpenWeb());
{
SPList tasksList=web.Lists["Tasks"];
DataTable dt=tasksList.Items.GetDataTable();
foreach(DataRow dr in dt.Rows)
{
//Code
}
}

No comments:

Post a Comment