SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 1 down vote accepted

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

share|improve this answer
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 '10 at 5:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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