Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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

 
discard

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.