简体   繁体   中英

Data returned if GetItems if query did not match

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:

SPList list = ...
list.Items.Add(); 

This loads all the items in the list, which might be slow for large item sets.

SPList.AddItem() retrieves the SPListItemCollection by executing a CAML query that returns no items (ID == -1) and calls then the Add method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM