1

1) I am getting list items from a list by CAML query in ListItemCollection objects of Max 5000 items

2) I am pushing each ListItemCollection into a List of ListItem to enable the capability of querying via LINQ. I am using ListItemCollection position to continue from the next 5000 list items.

3) I want to do some querying by 2 specific fields in 2 different scenarios. Both fields are Lookup fields looking into 2 different libraries.

One of them is working, the other is not. I get:

The given key was not present in this dictionary

I tried replicating the non-working column with another one created from scratch. I still got the same error.

I noticed that when traversing the List by a ForEach, if I do not load each ListItem by context.Load, I do not see all the fields within the ListItem. Case in point, if I do not do:

ctx.Load(item);
ctx.ExecuteQuery()

I can extract:

item.FieldValues["Column1"]

but not:

item.FieldValues["Column2"]

or:

item.FieldValues["Column3"]

I need to be able to load all the FieldValues of all the items either at 1) or 2). For sure, this cannot be done by a Foreach as it would take ages and will defeat the purpose of using CAML Query and LINQ.

  • try just item["Column1"] and item["Column2"] – Mike May 30 '17 at 16:37
  • I tried it at the moment of populating the List<ListItem> items. items[0]["Column1"] loads but not Column2. Also in LINQ, I don't think you can do: c => c["Column1"] != null but rather c=> c.FieldValues["Column1"] != null (for e.g.) – Jurgen Cuschieri May 30 '17 at 16:47
  • 1
    What ViewFields are you requesting with your CAML query? Be sure you're specifying both fields. – theChrisKent May 30 '17 at 17:03
  • This is how I am assigning the CAML Query. I am not specifying any fields - Should it be done in another way?: camlQuery.ViewXml = "<View Scope='RecursiveAll'><RowLimit>5000</RowLimit></View>"; – Jurgen Cuschieri May 31 '17 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.