Tuesday, December 8, 2009

Site Collection dispose is enough no more web dispose

In SP2010 OM site collection dispose will dispose all the webs opened on top of that site collection, this is different from the MOSS/WSS in which developer has to call the disose on each web.

 

using()-> will calls the dispose once its scope is finished.

 

SPS2010 / WSF 4.0:

 

using(SPSite mySite = new SPSite())

{

                SPWeb myWeb = new mySite.RootWeb();

                {

}

}

 

MOSS 2007/ WSS 3.0:

 

using(SPSite mySite = new SPSite())

{

                Using(SPWeb myWeb = new mySite.RootWeb())

                {

}

}

 

0 comments: