1

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 ?

btw

p.Fields["WF_Approver"].ToString()==approver.loginname 

didn't work either.

Thanks

cranfan
  • 129
  • 1
  • 3
  • 14

1 Answers1

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 '10 at 05:56