迭代 DataView 进行更新
我有一个 DataView,
inputView.RowFilter = "isnull(" + ID1 + ",'')<>'' and isnull(" + reason + ",0)=0";
在此过滤器之后进行过滤,我必须将 inputView
的“IsVerified
”列更新为“1”
LINQ 中是否有某些内容可以执行以下操作?
inputView.RowFilter.ForEach(x=>x.Field<IsVerified> =1);
I have a DataView which filters
inputView.RowFilter = "isnull(" + ID1 + ",'')<>'' and isnull(" + reason + ",0)=0";
after this filter i have to update "IsVerified
" column of inputView
to "1"
Is there something in LINQ to execute the following?
inputView.RowFilter.ForEach(x=>x.Field<IsVerified> =1);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要在 DataView 上使用 LINQ,则必须在 DataView 上创建自己的扩展方法。 DataView 本身没有 .
ToList()
方法,而 .ForEach()
是在该方法中定义的。为 DataView 创建扩展方法。
您的 DataView 现在可以这样调用:
一些开发人员可能更喜欢完整的 .NET
foreach (var x in y)
语句,但是这个也会做同样的事情。完整的控制台应用程序概念验证:http://pastebin.com/y9z5n6VH
If you want to use LINQ on your DataView, you'll have to create your own extension method on the DataView. The DataView does not natively have a .
ToList()
method, which is where the .ForEach()
is defined.Create your Extension Method for the DataView.
Your DataView can now be called this like:
Some developers may prefer the full .NET
foreach (var x in y)
statement, but this will do the same.A full console application proo-of-concept: http://pastebin.com/y9z5n6VH