SharePoint Asked by K. Jones on December 24, 2020
Rather than repeatedly query a SharePoint list for information I need, I wanted to create a dictionary from an SPListItemCollection
(where the dictionary key is the “Title” value of each SPListItem
, and the value is the SPListItem
itself). I tried this:
SPListItemCollection documentCodesListItems = documentCodesList.GetItems(query);
Dictionary<string, SPListItem> dictionary = (from SPListItem i in documentCodesListItems select new { Key = i.Title, Value = (SPListItem)i }).ToDictionary(
a => a.Key,
a => a.Value);
But I get "Value does not fall within the expected range."
exception. Can anybody see my mistake, or should I do this differently?
I was able to reproduce following error when my CAML query is wrong. So it's time to re-check your CAML query again.
Value does not fall within the expected range.
Generating Dictionary from items is perfect. You have to consider following thing while generating Dictionary from items where Title
is the Key
of Dictionary.
Keys can not be duplicate for Dictionary
Use u2u caml builder for building CAML query
Answered by Atish Dipongkor - MVP on December 24, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP