【问题标题】:BLToolkit update with non IQueryable带有非 IQueryable 的 BLToolkit 更新
【发布时间】:2011-09-12 21:20:26
【问题描述】:

到目前为止,如果我想更新表格,我正在使用类似的东西。

var myData = from t1 in db.Table1
where ...
select new { do some math here };

然后我会打电话

myData.Update( db.Table2, x => new Table2
{
    update columns here
}

这很好用,但现在我需要将 myData 查询转换为 List(),以便稍后在另一个更新调用中使用相同的数据。 IQueryable 的问题在于,当我稍后在代码中使用此“myData”第二次调用 Update 时,它​​包含在两次更新之间受到影响的数据,并且我希望数据保持在调用第一次更新之前的状态。

所以我需要这个

var myData = (from t1 in db.Table1
where ...
select new { do some math here }).ToList();

使用与以前相同的调用来更新表。

【问题讨论】:

    标签: list bltoolkit


    【解决方案1】:
    var myData =
        from t1 in db.Table1
        where ...
        select new { do some math here };
    
    var myDataList = myData.ToList();
    
    myData.Update( db.Table2, x => new Table2
    {
       update columns here
    }
    

    这是你要找的吗?

    【讨论】:

    • 不完全是。我需要这个 myDataList.Update( db.Table2, x => new Table2 { update columns here } 但这是不可能的,因为 myDataList 现在是对象而不是查询
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 2011-02-24
    • 2011-11-14
    相关资源
    最近更新 更多