I'm using SPList.GetItems(string fields[]) to obtain only specific item fields from a document library:
SPListItemCollection items = list.GetItems("UniqueId", "Name");
However, iterating the items
collection reveals that I can easily access even fields that I didn't explicitly retrieve, while I would be expecting an exception:
foreach (var item in items)
{
var id = item.UniqueId;
var name = item.Name;
var url = item.Url; // I didn't request this field yet here it is.. no exception thrown.
Console.WriteLine("{0} {1} {2}", url, name, id); // normally displays every value
}
Why is that? Does SharePoint simply pull everything from the database if it encounters a parameter that hasn't been queried? Am I misunderstanding what 'fields' refer to here?
SPListItemCollection items = list.GetItems(new string[]{"UniqueId", "Name"});
params string[]
, so comma-separated values are legit.