Dapper: Equals / GetHashCode inconsistent in Identity object

Created on 10 Sep 2018  路  1Comment  路  Source: StackExchange/Dapper

Hi,
is there a reason why when pre-computing hashCode in Identity, otherTypes parameter is included but when comparing to other in Equals, it is not included?

https://github.com/StackExchange/Dapper/blob/master/Dapper/SqlMapper.Identity.cs

AFAIK, when two object equal, they should have the same hashcode, but if two identity objects were created with different otherTypes parameter, they won't.

We are occasionally seeing a production exception coming from multimap caused by an incorrect type cast. We think it might be caused by the same sql query used in MultiMap with different generic parameters where a deserializer cached for type X is returned for a different type Y. But we can't reproduce it reliably though.

Update: we linked our project to dapper source code for another round of debugging and now we are pretty sure our issue is caused by the Equals/GetHashCode inconsistency.

Most helpful comment

I'd agree that looks like a bug. Thanks, we'll get that fixed.

>All comments

I'd agree that looks like a bug. Thanks, we'll get that fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amanguptamindtree picture amanguptamindtree  路  4Comments

fishjimi picture fishjimi  路  5Comments

yozawiratama picture yozawiratama  路  5Comments

CrescentFresh picture CrescentFresh  路  4Comments

silkfire picture silkfire  路  4Comments