回答編集履歴
1
追加
test
CHANGED
@@ -38,17 +38,11 @@
|
|
38
38
|
|
39
39
|
//削除対象をマークする
|
40
40
|
|
41
|
-
foreach(var
|
41
|
+
foreach (var y in result.Where(y => haishiBunrui.Any(x => y.bunrui_cd == x)))
|
42
42
|
|
43
43
|
{
|
44
44
|
|
45
|
-
foreach(var y in result.Where(y => y.bunrui_cd == x))
|
46
|
-
|
47
|
-
{
|
48
|
-
|
49
|
-
|
45
|
+
y.delete = true;
|
50
|
-
|
51
|
-
}
|
52
46
|
|
53
47
|
}
|
54
48
|
|
@@ -77,3 +71,41 @@
|
|
77
71
|
}
|
78
72
|
|
79
73
|
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
無理やりLINQ使ってみた。
|
78
|
+
|
79
|
+
```C#
|
80
|
+
|
81
|
+
var test = db.Select(y => haishiBunrui.Any(x => y.bunrui_cd == x)
|
82
|
+
|
83
|
+
? new Result { machine_cd = y.machine_cd, bunrui_cd = y.bunrui_cd, delete = true }
|
84
|
+
|
85
|
+
: new Result { machine_cd = y.machine_cd, bunrui_cd = y.bunrui_cd, delete = false })
|
86
|
+
|
87
|
+
.GroupBy(g => g.machine_cd);
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
//テスト
|
92
|
+
|
93
|
+
foreach (var g in test)
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
if (g.All(x => x.delete == true))
|
98
|
+
|
99
|
+
{
|
100
|
+
|
101
|
+
Console.WriteLine($"マシンコード({g.Key})は削除できません。");
|
102
|
+
|
103
|
+
var 分類 = g.Select(y => y.bunrui_cd).ToList();
|
104
|
+
|
105
|
+
Console.WriteLine($"対象分類は({string.Join(",", 分類)})");
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
```
|