Do not instantiate an SPWeb, SPSite, SPList, or SPListItem object within an event receiver. Event receivers that instantiate these objects instead of using the instances passed via the event properties can cause the following issues:
- Significant additional roundtrips to the database (one write operation can result in up to five additional roundtrips in each event receiver).
- Calls to the Update method on these instances can cause subsequent Update calls in other registered event receivers to fail.
This is not good:
This is good:
get Site/web/List from the properties
Optomizing Code Performance
Recommended (one step at a time!!!!)
Don’t Create SPSite/SPWebt if you don’t have to
You can get a reference to the WebApplication without creating SPSite/SPWeb, using WebApplication.Lookup (URI)