views:

1358

answers:

1

I simply want to achieve this line of SQL:

UPDATE table1
SET table1.col = table2.col
FROM table2 INNER JOIN
     table1 ON table2.id = table1.id

How can that be done using entity framwork with minimal number of roundtrips?
All I can think of is using foreach to loop through my table2 and update it's related entry in table1. But that does lead to a whole lot of roundtrips don't it?

A: 

There is, unfortunately, no UPDATE in Entity SQL at present. A workaround is to use regular SQL. Without this, keep the number of round trips to a minimum by loading all required rows from both tables at once and calling SaveChanges as few times as possible.

Craig Stuntz