-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong comparison of GUID (aka UniqueIdentifier) values #129
Comments
Hello @TYROTOXIN , Thank for letting us known. We are currently looking at all open issues to clean/make them, so we will eventually soon check this one as well. Best Regards, Jonathan Performance Libraries Runtime Evaluation |
Hello @TYROTOXIN , We started to investigate this issue. However, we are not sure how you use the Could you provide a code example of how you use it when the provider is SQL Server? Perhaps that will help us to better understand to find a solution. Best Regards, Jonathan |
Yeah, it's very simple. Consider such case: class Record
{
public Guid Id { get; set; }
}
class SampleDbContext
{
DbSet<Record> Records { get; set; }
}
...
// Example 1: Filtering
Guid minId = ...;
var records = dbContext.Records.Where(r => r.Id.CompareTo(minId) >= 0).ToList();
....
// Example 2: Ordering
var records = dbContext.Records.OrderBy(r => r.Id).ToList(); |
Hello @TYROTOXIN , Thank for the additional information. |
SQL Server has a slightly different way of comparing GUID values as opposed to .NET implementation, so operators like Less and Greater return unexpected results with the Effort.
.NET framework compares first 4 bytes (
uint
), then next 2 bytes (ushort
), then next 2 bytes (ushort
), then rest of 8 bytes one by one.And here is an example of how SQL Server does comparison of GUIDs: https://stackoverflow.com/questions/6945878/how-is-a-guid-actually-stored-and-sorted-compared-in-sql-server#answer-49300469
The text was updated successfully, but these errors were encountered: