开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜