コンテンツへスキップ
ものがたり
戻る

2008-05-12

DLinqの仕事が降ってきてしまった

linqの中でも特に興味が無い分野だったので全然知らないに等しいのだけど、まあなるべくさっさとやっつけて次に行きたいと思います。しかしid:atsushieno:20070225の予想は大ハズレだな。

しかし世の中うさんくさいドメインを取得する人はいるもので、こんなのがちゃっかり取られて活用されているようです。
http://linq.to/

既知の全プロバイダの一覧とか眺めてみるとまあ面白いかも。

DataRowComparer weird behavior

のっけから躓かされているような。

http://msdn.microsoft.com/en-us/library/bb908065.aspx

The GetHashCode method is the value-based comparison implementation of the GetHashCode method.

と書いてあるのだけど

DataSet ds = new DataSet ();
DataTable dt = new DataTable ("MyTable");
ds.Tables.Add (dt);
dt.Columns.Add ("col1");
dt.Columns.Add ("col2");
DataRow r1 = dt.Rows.Add (new object [] {"foo", "bar"});
DataRow r2 = dt.Rows.Add (new object [] {"foo", "bar"});
ds.AcceptChanges ();
DataRowComparer<DataRow> c = DataRowComparer.Default;
Assert.IsTrue (c.GetHashCode (r1) == c.GetHashCode (r2), "#1");
r2 ["col2"] = "baz";
r2.AcceptChanges ();
// .NET fails here
Assert.IsFalse (c.GetHashCode (r1) == c.GetHashCode (r2), "#2");
DataRow r3 = dt.Rows.Add (new object [] {"foo", "baz"});
// .NET fails here
Assert.IsFalse (c.GetHashCode (r1) == c.GetHashCode (r3), "#3");

何を渡しても同じhashが帰ってきているみたい。なんで??


この記事を共有:

前の記事
DataRowComparer weird behavior
次の記事
DLinqの仕事が降ってきてしまった