BLToolkit更新加入

时间:2011-07-17 17:40:12

标签: sql join bltoolkit

任何人都知道如何使用BLToolkit语法编写以下更新代码,我需要连接两个表,并更新其中一个表。在SQL Server中,这样做:

update Table1 set
    Col1 = T.Col1 - TT.Col2
from
    @tempTable as TT
    inner join Table1 as T on **T.ColX = TT.ColX and T.ColY = TT.ColY**

到目前为止,这是我完成更新的方式。

 db.SomeTable.Where( x => x.ColName == someColName )
                            .Update( x => new SomeTable
                            {
                                //update columns here
                            } );

1 个答案:

答案 0 :(得分:1)

BLToolkit单元测试示例:

var q =
    from c in db.Child
    join p in db.Parent on c.ParentID equals p.ParentID
    where c.ChildID == id && c.Parent.Value1 == 1
    select new { c, p };

q.Update(db.Child, _ => new Child { ChildID = _.c.ChildID + 1, ParentID = _.p.ParentID });
相关问题