我想DataTable
使用Linq
和更新记录Lambda Expression
。我可以更新如下一栏
dtProduct.AsEnumerable().Where(i => i.Field<long>("ProductId") == Convert.ToInt64(id)).First().SetField("Qty", qty);
无法理解如何更新其他:(。我最终为每列写了几次更新。
最后,我为每列写了几次更新。
您的代码包括两部分:
您可以通过引入变量来重用定位实例的结果:
var inst = dtProduct.AsEnumerable().Where(i => i.Field<long>("ProductId") == Convert.ToInt64(id)).First();
现在您可以SetField
多次调用它:
inst.SetField("Qty", qty);
inst.SetField("Price", price);
inst.SetField("Weight", weight);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句