0

I want to do something like the below. But I'm not sure how exactly to do it. I just want to return items with similar Title to be efficient.

List pages = clientContext.Site.RootWeb.Lists.GetByTitle("Web Part Gallery");

ListItemCollection existingWebParts = pages.GetItems(CamlQuery.CreateAllItemsQuery());

clientContext.Load(existingWebParts, items => items.Include(item => item["Title"]).Where(obj => obj == "CollapsibleAccordion.webpart"));

clientContext.ExecuteQuery();

This is showing as syntax error.

1

1 Answer 1

0

You are comparing an object with a string inside the lambda expression. I mean following part is causing the syntax error

.Where(obj => obj == "CollapsibleAccordion.webpart")

You should "CollapsibleAccordion.webpart" with a column like Title or etc.

clientContext.Load(existingWebParts, items => items.Include(item => item["Title"]).Where(obj => obj["Title"] == "CollapsibleAccordion.webpart"));
1
  • Thanks Atish. Unfortunately, it gives me this error: Additional information: The expression (obj.get_Item("Title") == "CollapsibleAccordion.webpart") is not supported. Instead, I used CamlQuery to get only the webpart I need. Thanks
    – Water
    Oct 25, 2015 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.