In ItemCheckingIn and ItemCheckedId event handlers, I need elevated site since I'm deleting / adding new documents.
public override void ItemCheckedIn(SPItemEventProperties properties)
using (SPSite site = SecurityHelper.GetElevatedSite(properties.ListItem.Web.Site))
using (SPWeb web = site.OpenWeb(properties.ListItem.Web.ID))
// do some strange things
But according to the best practices, Its a bad idea to instantiate a new SPSite and SPWeb object. (obviously, for performance reasons..)
Since I need elaveted web in both event handlers, I'll have double performance penalty. I was thinking to make us of caching, but SPSite or SPWeb is not thread safe, so cannat be cached..
Is there any better way ?
View Complete Post