如何在临qu更新变量 [英] how to update varible in linqu

查看:139
本文介绍了如何在临qu更新变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是代码
我已经获取了getdat中的值,然后我使用for循环遍历数据
我希望getdat中的数据应反映我所做的更改
怎么做


Here is the code
i have retrieve the values in getdat and after that i am looping through the data using a for loop
i want that the data in the getdat should reflect the changes i have done
how to do it


dbWebEnrollDataContext dt1 = new dbWebEnrollDataContext();
var getdat=from o in dt.Trade
           join c in dt.tradevalue on o.id equal c.id
           select new {o.firstvalue,c.secondvalue};
    foreach(var data in getdat)
   {
    data.firstvalue="sdfsdf";
   }

推荐答案

假设我理解您的问题,您可以作弊"并做类似
的事情
assuming i understand your question , you can "cheat" and do something like

var changesomething = new Func<Person, bool>((p) => { p.Name += " I changed this"; return true; });
var these = ( from p in people
              where p.Age%2==0
              where changesomething(p)
              select p);


这篇关于如何在临qu更新变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆