Usher
Usher

Reputation: 2146

Linq to Entity - Join Update

This might be easy for you guys but am stuck to convert into linq. here is my sql query

update Sevt set
 UserFlag4 = 0
from Sevt, Wo W
where Sevt.Seqnum = W.SeqNum and w.WONUM = '1502411'

Here is two table joined but not sure how to convert in to LINQ. Any help much appreciated, Thanks in Advance

Upvotes: 0

Views: 1517

Answers (1)

david.s
david.s

Reputation: 11403

Just select from both tables as you would in SQL. Then update the flag and save changes.

var query = from s in context.Sevt
            from w in context.Wo
            where s.Seqnum == w.SeqNum && w.WONUM == "1502411"
            select s;
foreach (var set in query)
{
    set.UserFlag4 = 0;
}
context.SaveChanges();

Upvotes: 2

Related Questions