DataTable.Mergeってことですかね?
追記
とりあえず書いてみました。
C#
1 static void Main(string[] args)
2 {
3 DataTable tableA = new DataTable();
4 DataTable tableB;
5
6 tableA.Columns.Add("ColumnA");
7 tableA.Columns.Add("ColumnB");
8 tableA.Columns.Add("ColumnC");
9 tableA.Columns.Add("ColumnD");
10
11 tableB = tableA.Clone();
12
13 //TableAのデータ作成
14 tableA.Rows.Add(100, "AAA", "abc", 500);
15 tableA.Rows.Add(100, "AAA", "abc", 600);
16 tableA.Rows.Add(101, "BBB", "bbb", 200);
17 tableA.Rows.Add(102, "CCC", "ccc", 1000);
18 tableA.Rows.Add(106, "FFF", "fff", 400);
19
20 //TableBのデータ作成
21 tableB.Rows.Add(100, "AAA", "abc", 500); //同じレコード
22 tableB.Rows.Add(100, "AAA", "abc", 700); //一部のカラムの値が異なる
23 tableB.Rows.Add(105, "EEE", "eee", 2000); //全部違う
24
25 //LINQ
26 var rows = tableA.AsEnumerable().Union(tableB.AsEnumerable(), DataRowComparer<DataRow>.Default);
27 //DataRowの塊なので、とりあえずDataTableに入れる
28 DataTable tableC = tableA.Clone();
29 foreach (DataRow r in rows)
30 {
31 tableC.ImportRow(r);
32 }
33 ViewTable(tableC);
34
35 Console.WriteLine('\n');
36
37 //Selectで
38 tableA.CaseSensitive = true;
39 foreach (DataRow r in tableB.Rows)
40 {
41 string where = $"ColumnA = {r["ColumnA"]} AND ColumnB = '{r["ColumnB"]}' AND ColumnC = '{r["ColumnC"]}' AND ColumnD = {r["ColumnD"]}";
42
43 if (tableA.Select(where).Length == 0) tableA.ImportRow(r);
44 }
45 ViewTable(tableA);
46
47
48
49 Console.ReadKey();
50 }
51
52 static void ViewTable(DataTable t)
53 {
54 foreach (DataRow r in t.Rows)
55 {
56 foreach (Object item in r.ItemArray)
57 {
58 Console.Write(item.ToString() + '\t');
59 }
60 Console.Write('\n');
61 }
62
63 }
64
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/17 04:54
2018/11/17 08:51
2018/11/17 09:44
2018/11/17 09:48
2018/11/17 10:42
2018/11/21 07:15