Bug with Anonymous types and hashcodes


After several thousand queries using anonymous types, the server-side of interlinq became unbelievably slow. I tracked this down the the fact that it's emitting a new dynamic type each and every time the query is called and not reusing the cached types at all.
The reason is that the GetHashCode is not being calculated correctly in AnonymousMetaType
num ^= EqualityComparer<List<AnonymousMetaProperty>>.Default.GetHashCode( this.m_metaProperties );
is actually comparing with the instance of List<AnonymousMetaProperty>, which is always different.
this.m_metaProperties.ForEach((o) => num ^= EqualityComparer<AnonymousMetaProperty>.Default.GetHashCode(o));
solves the problem. You need to do the same in InterLinqType; replace
num ^= EqualityComparer<List<InterLinqType>>.Default.GetHashCode( this.m_genericArguments );
this.m_genericArguments.ForEach((o) => num ^= EqualityComparer<InterLinqType>.Default.GetHashCode(o));
Closed Nov 4, 2008 at 9:55 AM by domcon