Print Page | Close Window

Bug/Issue with orderby GUIDs in cache

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1985
Printed Date: 13-Oct-2025 at 12:44pm


Topic: Bug/Issue with orderby GUIDs in cache
Posted By: jsobell
Subject: Bug/Issue with orderby GUIDs in cache
Date Posted: 20-Jul-2010 at 11:24pm
Slightly unusual bug here...

SQL Server does not order GUIDs in the same way as .NET, so if you query against the cache you will get very different search order results to the server's returned order.

According to Microsoft's doco the SQL Server uses only the last eight digits of the GUID for sorting. This is a total pain in the bum, but such is life.
We use the following extension to Guid to ensure our internal sorts match SQL Server's:

public static int CompareToSql(this Guid left, Guid value)
{
  return (left.ToString().Substring(24).CompareTo(value.ToString().Substring(24)));
}

The cache in DF appears to do a regular sort, so in some cases (such as ours, surprise surprise) it breaks if the QueryStrategy is not set to QueryStrategy.DataSourceOnly

Just another interesting issue found while converting an EF4 app to IdeaBlade :)

I'll include this in an incident report.



Replies:
Posted By: ting
Date Posted: 21-Jul-2010 at 7:09pm

Yep, we ran into this as well.  We'll take care of it along with the String equality issues. ;)




Print Page | Close Window