INNER CODE UNIT · C#
groups
Nonanti/PipeFlow · samples/PipeFlow.Sandbox/Program.cs:316
var groups = rows.GroupBy(r => r["Dept"]).ToDictionary(g => (string)g.Key!, g => g.Count());
return groups["Eng"] == 2 && groups["HR"] == 1;
});
runner.Run("3.10 DataRow as Dictionary key (round-trip lookup)", () =>
{
var key1 = new DataRow { ["Id"] = 1 };
var key2 = new DataRow { ["Id"] = 1 }; // structurally equal to key1
var dict = new Dictionary<DataRow, string> { [key1] = "first-insertion" };
return dict.ContainsKey(key2) && dict[key2] == "first-insertion";
});
runner.Run("3.11 mutation invalidates cached hash", () =>
{
var row = new DataRow { ["X"] = 1 };
var before = row.GetHashCode();
row["X"] = 99;
var after = row.GetHashCode();