从 Linq 中的数据表中选择不同的行
我试图根据多个列(attribute1_name、attribute2_name)获取不同的行,并使用 Linq-to-Dataset 从数据表中获取数据行。
我想要这样的结果
attribute1_name attribute2_name
-------------- ---------------
Age State
Age weekend_percent
Age statebreaklaw
Age Annual Sales
Age Assortment
How to do Thin Linq-to-dataset?
I am trying to get distinct rows based on multiple columns (attribute1_name, attribute2_name) and get datarows from datatable using Linq-to-Dataset.
I want results like this
attribute1_name attribute2_name
-------------- ---------------
Age State
Age weekend_percent
Age statebreaklaw
Age Annual Sales
Age Assortment
How to do thin Linq-to-dataset?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果它不是类型化数据集,那么您可能需要使用 Linq-to-DataSet 扩展方法执行类似的操作:
确保您的数据集开头有一个
using System.Data;
语句代码以启用 Linq-to-Dataset 扩展方法。希望这有帮助!
If it's not a typed dataset, then you probably want to do something like this, using the Linq-to-DataSet extension methods:
Make sure you have a
using System.Data;
statement at the beginning of your code in order to enable the Linq-to-Dataset extension methods.Hope this helps!
像这样:(假设有类型数据集)
Like this: (Assuming a typed dataset)
检查此链接
获取不同的行使用 Linq 从数据表(与多列不同)
或者尝试此
编辑:放置了缺少的第一个大括号。
Check this link
get distinct rows from datatable using Linq (distinct with mulitiple columns)
Or try this
EDIT: Placed the missing first curly brace.
我们可以得到类似于下面例子的distinct
We can get the distinct similar to the example shown below