我如何检查两个dataTable对象以包含另一个DataTable中的值?

时间:2014-03-18 10:06:19

标签: c# asp.net datatable row contains

嗨我有两个DataTable对象,我想逐步控制这两个DataTable:

例如,这里有两个DataTable:

DataTable "zugang"

Name
A
B
C
D

DataTable "abgang"

Name
C
D
E
F

步骤1:zugang columnvalue包含abgang coummvalue Herre我创建了一个新的DataTable"完成"列名称和状态

控制:zugang

A is not in abgang -> addRow(name=A,status=new)
B is not in abgang -> addRow(name=B,status=new)
C is in abgang     -> addRow(name=C,status=change)
D is in abgang     -> addRow(name=D,status=change)

第二步:abgang columnvalue不包含zugang columnvalue

控制:abgang

C is in zugang -> nothing
D is in zugang -> nothing
E is not in zugang -> addRow(name=E,status=delete)
F is not in zugang -> addRow(name=F,status=delete)

在此步骤之后,新的DataTable必须是这样的:

Name | Status
A      new
B      new
C      change
D      change
E      delete
F      delete

所以我可以用这三个状态值最终计算行:)

and I get -> new=2 , change=2 and delete=2

这是我的方法结构:

private static DataTable ControlDataTable(DataTable zugang, DataTable abgang) 
{
    DataTable endTable;

    //addcolumns 
    step 1:

    step2:

    return endtable;
}

0 个答案:

没有答案