比较数据集或更好的想法
如何比较一个数据集与另一个数据集的值。
第一个数据集 [“正确记录”] 来自 SQL Server,列名称
[id], [subsNumber]
第二个数据集 [“正确和不正确记录”] 来自进度数据库,具有不同的列,除了1 是 subsNumber
我如何去创建另一个数据集,其中包含 ["properrecords"] 中的所有 [subsNumber]
以及第二个数据集 ["proper inproper] 中的匹配记录记录”] ?
或
删除第二个数据集中的所有记录[“正确和不正确的记录”],这些记录与第一个数据集中的“subsNumber”列
或任何其他想法
基本上不匹配如何从具有相同“subsNumber”的第二个数据集中获取所有记录作为第一个数据集
How do I compare values of one data set from another.
1st dataset ["proper records"] is coming from SQL Server with column names
[id], [subsNumber]
2nd dataset ["proper and inproper records"] is coming from progress database, with different columns except 1 which is subsNumber
How do I go and make another dataset which has all the [subsNumber]
from ["proper records"] with matching records from 2nd datset ["proper inproper records"] ?
or
delete all the records in 2nd dataset["proper and inproper records"] which don't match the "subsNumber" column in the 1st dataset
or any other idea
basically How do I get all records from 2nd dataset which has same "subsNumber" as the 1st dataset
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关键是使用 System.Data.DataRelation 将 2 个数据表连接到一个公共列(或多个列)上。
以下是源自 KC's See 的帖子的一些代码夏普博客
The key is using System.Data.DataRelation to join your 2 datatables on a common column (or columns).
Here's some code derived from a post at KC's See Sharp Blog
我解决了问题:
第一个数据集--> 循环遍历并获取 subsNumber
调用函数并传递 subsNumber 和第二个数据集 --> 到它
然后为新数据集启动另一个循环
如果子编号不匹配则继续
如果 subsNumber 匹配该数据,例如将列添加到 sqlserver 表等
代码:
I solved the problem:
1st dataset--> loop throuhg and get the subsNumber
Call function and pass subsNumber and 2nd dataset--> to it
Then start another loop for new dataset
Continue if subsnumber don't match
If subsNumber match work on that data like add columns to sqlserver table etc.
code:
要从第二个数据集中获取与第一个数据集中的记录匹配的所有记录,如下所示:
IEnumerable list3 = list2.Where(l2=>list1.Contains(l1=>l1.subsNumber == l2.subsNumber) );
类似的东西!
To get all the records from 2nd dataset that match the records from the 1st dataset would be something like this:
IEnumerable list3 = list2.Where(l2=>list1.Contains(l1=>l1.subsNumber == l2.subsNumber));
Something along those lines!