Join and batch update in LINQ to SQL
Can something like this be written in LINQ to SQL:
UPDATE Table1
SET CustomerName = t2.Name
FROM T开发者_开发问答able1 t1 JOIN Table2 t2
ON t1.TableID = t2.TableID
var result = from t1 in context.Table1
join t2 in context.Table2 on t1.TableID = t2.TableID
select new {t1, t2};
result.ToList().ForEach(i => i.t1.CustomerName = i.t2.Name);
context.SubmitChanges();
精彩评论