The problem is in the == operator.
From MSDN:
"For reference types other than string, == returns true if its two
operands refer to the same object"
Let say we have 2 Oid objects that have equal content (just for
example 4c46d7657c1a601774000003) but have different references. It is
possible, right?
Oid o1 = Oid.NewOid();
Oid o2 = new Oid(o1);
Console.WriteLine(ReferenceEquals(o1, o2).ToString()); // False
Console.WriteLine(o1.Equals(o2).ToString()); // True
Console.WriteLine((o1==o2).ToString()); // True
Object x1 = o1;
Object x2 = o2;
Console.WriteLine(x1.Equals(x2).ToString()); // True
Console.WriteLine((x1 == x2).ToString()); // False <--- It's
here !!!!!!! operator is static, can't be virtual.
I have IKey interface that have System.Object as a Key property.
So Oid is actually stored as System.Object . Splitting data storage
from business logic (some explanations about it are at pic
http://i30.tinypic.com/2hx3vo5.png)
And the problem is that when we call operator == for Object it doesn't
call overloaded == from Oid, so we have false as a result.
As result I have to use
.Where(x=>x.Key.Equals(y.Key))
instead of
.Where(x=>x.Key==y.Key)
Anywhere, and often it goes to lower layers, to storage driver.
yes, it's a problem now.
Any thoughts ?