Here is my code.

SPUser approver = mySite.EnsureUser(approverId);
var selectedItems = listItems.Cast<SPListItem>().Where(p => p.Fields["WF_Approver"] == approver);

my list items field "WF_Approver" is field type of person or group. my approver is type of SPUser.

So how can i check the equation here between SPField and SPUser ?



didn't work either.


1 Answer 1


Try using this to get the SPUser from the field:

SPUser userFromField = 
    new SPFieldUserValue(web, p.Fields["WF_Approver"].ToString());

Where web is the current SPWeb

  • Thanks that casting didn't work but inspired me inanother way,i solved it like this p["WF_Approver"].ToString()==approver.loginname it is very easy but at that time i couldn't think this.
    – cranfan
    Jun 16, 2010 at 5:56

Your Answer

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

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