LINQ: update over an inner join

M

Michel Walsh

Is it possible to directly update over a join (by that, I mean without using
an explicit UPDATE SQL statement) over a join, in LINQ, when no relation
exists between the two tables?



DataContext db = new DataContext(connectionString);

var q1 = from a in db.tablea
from b in db.tableb
where a.ItemID= b.ItemID
select new{ upd = a.unitPrice, soso = b.unitPrice };
foreach( var w in q1)
{
w.upd = w.soso;
}
db.SubmitChanges();




does not work since w is not updateable.

Any suggestions?



Vanderghast, Access MVP
 
M

Marc Gravell

You would have to "select new {a,b} ", then makr your chanegs to the
underlying entities "w.a.unitPrice = w.b.unitPrice", and finally call
SubmitChanges();

If the data volumn is high you might want to look at a SP instead.

Marc
 
M

Michel Walsh

Exactly what I was looking for (Always sounds more evident once we have the
solution in the face :) )


Vanderghast, Access MVP
 
Top