Update records using LINQ

后端 未结 8 1578
迷失自我
迷失自我 2020-12-04 17:24

I need to set a value in a table for a subset of rows. In SQL, I would do this:

UPDATE dbo.Person SET is_default = 0 WHERE person_id = 5

Is

8条回答
  •  無奈伤痛
    2020-12-04 17:56

    Strangely, for me it's SubmitChanges as opposed to SaveChanges:

        foreach (var item in w)
        {
            if (Convert.ToInt32(e.CommandArgument) == item.ID)
            {
                item.Sort = 1;
            }
            else
            {
                item.Sort = null;
            }
            db.SubmitChanges();            
        }                   
    

提交回复
热议问题