Debugging A SharePointProgramA bug was found. In SharePoint 2007, spweb, spfolder, and splistitem all provide a convenient property bags feature to store custom property information, just like this:
Splistitem item = ...;
Item. properties ["myprop1"] = "propvalue1 ";
Item. properties ["myprop2"] = "propvalue2 ";
Item. Update ();
The bug I found is that some custom attributes stored in spweb. properties are not correctly saved to the content database. Check carefully and find out the cause. This small problem is indeed easy to becomeCodeSo Let's remind you.
Spfolder, splistitem property bags (that is, spfolder. properties/splistitem. properties) are implemented directly using a hashtable. When we call spfolder. update () or splistitem. when updating (), you can write the data in their property bags back to the content database.
However, spweb. properties is a custom sppropertybag class (inherited from system. collections. specialized. implemented by calling spweb. update () does not write the data in property bags back to the content database, but calls sppropertybag. update () method. Example:
Spweb web = spcontext. Current. Web;
Web. properties ["myprop1"] = "propvalue1 ";
Web. properties. Update ();
I don't know why they have such design differences, but I guess the biggest possibility is that the implementation of spfolder/splistitem and spweb is not written by a developer, the developer who wrote spfolder/splistitem thought it was enough to use a simple hashtable. The developer who wrote spweb thought it was necessary to define a sppropertybag class, in this way, the sppropertybag can be reused for different classes in the project that require the property bags feature. Unfortunately, as the old saying goes: "developers carefully designed the stuff for reuse, 90% of the possibilities will not be reused "...