Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use "using" when getting an object from SPContext?

Tags:

sharepoint

I am currently getting a SPListItemCollection in this way:

SPContext.Current.Web.List("Multimedia").GetItems(query)

According to a Microsoft article, "SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code."

My question is -should I enclose the above code within a using block? Or shouldn't I, considering that it comes from an SPContext object? Thank you.


1 Answers

It is not even about SPContext - SPListItemCollection does not implement IDisposable and can't be disposed.

Unless I am not getting your question correctly?

like image 164
Nemanja Trifunovic Avatar answered Feb 15 '26 09:02

Nemanja Trifunovic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!