sergey wrote:
Not sure why you think only one cache key is created. The fact that these two queries have equal hash code doesn't affect anything, it's just inefficient.
Here is the modification I add to do to make it work...
Do you agree with me ? If the 2 queries differs only by the value of their namedParameters, then they both have the same sqlQueryString. But in fact, it is 2 differents queries, that should have each one an entry in the Cache Query...
public int ComputeHashCode()
{
unchecked
{
int result = 13;
result = 37 * result + firstRow.GetHashCode();
result = 37 * result + maxRows.GetHashCode();
// NH - commented this out, namedParameters don't have a useful GetHashCode implementations
//result = 37 * result
// + ( namedParameters == null ? 0 : namedParameters.GetHashCode() );
// SGH ADDED
foreach (DictionaryEntry entry in namedParameters)
{
result = 37 * result + (entry.Value == null ? 0 : entry.Value.GetHashCode());
}
// SGH END
for (int i = 0; i < types.Length; i++)
{
result = 37 * result + (types[i] == null ? 0 : types[i].GetHashCode());
}
for (int i = 0; i < values.Length; i++)
{
result = 37 * result + (values[i] == null ? 0 : values[i].GetHashCode());
}
if (filters != null)
{
foreach (object filter in filters)
{
result = 37 * result + filter.GetHashCode();
}
}
result = 37 * result + (customTransformer == null ? 0 : customTransformer.GetHashCode());
result = 37 * result + sqlQueryString.GetHashCode();
return result;
}
}