I have two lists called "Department" and "Employee", in Employee has a lookup employee depart to the "Department" list

I need to know how can I do the update Employee information and department column by using linq to SharePoint?

Please advice.!

1 Answer 1


Try this code:

var result = ((from item in web.Lists["Employee"].Items.Cast<SPListItem>()  // Change Employee list name
              from deptitem in web.Lists["Department"].Items.Cast<SPListItem>() // Change Department list name
               where item.ID == 50 && deptitem.Title == "Dept2"   // Department title which you want to update
                    select new {  item, deptitem }).All(x =>
                         x.item["Title"] = "Updated";
                         x.item["Department"] = x.deptitem.ID;
                         return true;

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.