Not entirely sure what you're trying to do.... assuming you want to update the whole table, you could try something like this:
- load the whole table into memory as a
List<StcDocItems>
- loop over each item and see if it has a matching entry - if so, update it
So this would be the code to do this:
public class StcDocItems
{
public int Id { get; set; }
public int PartRef { get; set; }
public int DocRefType { get; set; }
public int? ItemRef { get; set; }
}
using(YourDbContext ctx = new YourDbContext())
{
// get all rows from table
List<StcDocItems> allItems = ctx.StcDocItems.ToList();
// iterate over items
foreach(StcDocItems item in allItems)
{
// do we find a row which has "ItemRef = Id" and "DocTypeRef = 63" ?
StcDocItems updateToItem = allItems.FirstOrDefault(i => i.ItemRef = item.Id && i.DocTypeRef = 63);
// if we found an item
if(updateToItem != null)
{
// set the partRef to new item's partRef
item.PartRef = i.PartRef;
}
}
// save any changes back to database table
ctx.SaveChanges();
}