This is really a simple question. What does GetItems
method return if SPQuery
object did not find any match? if i call the update method, if it did find anything. Will it add it?
I'm at the point of investigating a bug and I still don't have a environment for me to test and I'm new to SharePoint development so guys, please be gentle :D
The item will be added anyway. It doesn't matter if there are any items in the
SPListItemCollection
.SPList.AddItem()
uses this behavior to avoid loading all of the items in the list. One could write:This loads all the items in the list, which might be slow for large item sets.
SPList.AddItem()
retrieves theSPListItemCollection
by executing a CAML query that returns no items (ID == -1) and calls then theAdd
method.