DataTable选择过滤器,而不是“之间”

编程入门 行业动态 更新时间:2024-10-23 07:23:12
本文介绍了DataTable选择过滤器,而不是“之间”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想过滤一个价格范围的数据表。我想删除不在(例如)2和7之间的所有内容。在SQL中,我会做:NOT(2到7之间的价格)。但是在我的过滤器表达式中,我无法使用关键字between。什么是最好的解决方案?

I want to filter a datatable with a price range. I want to remove everything that is not between (for example) 2 and 7. In SQL I would do: NOT( price between 2 and 7). But in my filter expression I cannot use the keyword 'between'. What is the best solution?

推荐答案

如果您引用 System.Data.DataSetExtensions LINQ for DataTables),您可以执行以下操作:

If you are referencing System.Data.DataSetExtensions (which enables LINQ for DataTables), you can do the following:

var query = myDataTable.Where(c => !(c.Price >= 2 && c.Price <= 7)); var myDataView = query.AsDataView(); // if you want to databind...

更多推荐

DataTable选择过滤器,而不是“之间”

本文发布于:2023-11-09 21:14:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573454.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   而不是   DataTable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!