Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 比较两个数据集并将值放入新数据集中_C#_Asp.net_Ado.net - Fatal编程技术网

C# 比较两个数据集并将值放入新数据集中

C# 比较两个数据集并将值放入新数据集中,c#,asp.net,ado.net,C#,Asp.net,Ado.net,我正在使用C#在ASP.NET上工作, 我需要将两个数据集中的数据与两个数据集中的“ID”进行比较,然后将所有匹配行添加到新数据集中 在每个数据集中的表之间设置DataRelation,然后使用GetChildRows方法查找匹配项,然后将其添加到新数据集或任何其他数据结构中。请参阅以获取一些示例。在每个数据集中的表之间设置数据关系,然后使用GetChildRows方法查找匹配项,然后可以将这些匹配项添加到新数据集或任何其他数据结构中。有关一些示例,请参见。这可以通过两个数据表的交集来完成 us

我正在使用C#在ASP.NET上工作,
我需要将两个数据集中的数据与两个数据集中的“ID”进行比较,然后将所有匹配行添加到新数据集中

在每个数据集中的表之间设置DataRelation,然后使用GetChildRows方法查找匹配项,然后将其添加到新数据集或任何其他数据结构中。请参阅以获取一些示例。

在每个数据集中的表之间设置数据关系,然后使用GetChildRows方法查找匹配项,然后可以将这些匹配项添加到新数据集或任何其他数据结构中。有关一些示例,请参见。

这可以通过两个数据表的交集来完成

using System.Data;

public static class DataTableExtensions
{
    public static IEnumerable<DataRow> Intersect(this DataTable table, DataTable other)
    {
        return table.AsEnumerable().Intersect(other.AsEnumerable());
    }

    public static IEnumerable<DataRow> Intersect(this DataTable table, DataTable other, IEqualityComparer<DataRow> comparer)
    {
        return table.AsEnumerable().Intersect(other.AsEnumerable(), comparer);
    }
}

如果这不是您想要的,请发布更多详细信息。

这可以通过两个数据表的交集来完成

using System.Data;

public static class DataTableExtensions
{
    public static IEnumerable<DataRow> Intersect(this DataTable table, DataTable other)
    {
        return table.AsEnumerable().Intersect(other.AsEnumerable());
    }

    public static IEnumerable<DataRow> Intersect(this DataTable table, DataTable other, IEqualityComparer<DataRow> comparer)
    {
        return table.AsEnumerable().Intersect(other.AsEnumerable(), comparer);
    }
}

如果这不是您想要的,请发布更多详细信息。

您自己尝试过解决这个问题吗?你有什么困难?或者你想让我们给你一个完整的解决方案,没有做任何研究?你有没有尝试过自己解决这个问题?你有什么困难?或者你想让我们给你一个完整的解决方案,没有做任何研究?这有什么帮助?intersect如何定义行关系?“我需要将两个数据集中的数据与两个数据集中的“ID”进行比较”如果模式相同,则为intersect。这有什么帮助?intersect如何定义行关系?“我需要将两个数据集中的数据与两个数据集中的“ID”进行比较,如果模式相同,则“ID”是相交的。