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 there a way to do this in LINQ?
I currently use the:
var result = (from p in Context.People....)
notation.
Is there an update method I can use? Or do I have to get all the records, then update them one-by-one in a Foreach?
Is this the most efficient way, if this is even possible?
(from p in Context.person_account_portfolio where p.person_id == personId select p)
.ToList()
.ForEach(
x =>
x.is_default =
false);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…