I have a sharepoint 2010 list. I'm writing code against the client object model.
I use CAML to retrieve a set of sharepoint list items.
After that, I need to filter for a subset of these records, based on info that is stored in a People Picker column. (So I only wanna get results, where e.g. the PeoplePicker is set to John Smith.)
I know that in order to access the peoplepicker, it has to be declared as a FieldUserValue. However, I can't seem to do that within a lambda expression.
The below is how things should work ideally. But of course this doesnt compile as I cant declare the "EngineerAccount" as a FieldUserValue within the lambda expression.
FieldUserValue usvAss = i["EngineerAccount"] as FieldUserValue;
double totalTT = collListItemAss.Where(item => item["EngineerAccount"] as FieldUserValue == usvAss.LookupValue).Sum(sItem => Convert.ToDouble(sItem["field3"]));
Any ideas?
I'm sorry this is not solved.
I have 3 points.
1: This part seems to be unneccessary
`item["EngineerAccount"].GetType() == typeof(FieldUserValue)
2: This code doesnt comply. Also, it is logically incorrect. The "FieldUserValue" is a complex field containing multiple information. The problem is that I'm trying to 'equate" a FieldUserValue with a string, two different types.
(FieldUserValue)item["EngineerAccount"] == usvAss.LookupValue
3: Logically, it should be like this, but this doesnt work:
(FieldUserValue)item["EngineerAccount"].LookupValue == usvAss.LookupValue
Please help, I'm out of ideas right now!