Solving strange errors when updating more items in hooks

Sometimes when you’re updating item in hooks, you’ll receive strange error messages in the client. The reason for this is quite clear. Sitecore has an event system divided in 2 parts: the regular events such as item:created. The other one is the NotificationContext. This particular class is used by the Sitecore client to get notified before time intensive actions such as event broadcasting is done.
You can use this functionality as well by simply subscribing to the delegates in Sitecore.Context.Notifications.

But what if you’re updating or manipulating your repository triggered by a client action? Exactly, the client has subscribed to a specific action, but when the event will be triggered, a collection has changed or a DataContext is missing. The solution is easy: use Sitecore.Data.BulkUpdataContext in a using statement:

using(new Sitecore.Data.BulkUpdate())

{

//Your update code

}

Nobody gets notified, but important events(configured in the web.config/include files) will get triggered.

Have fun coding!