-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Unable to order by Guid column #10198
Comments
@chris31389 This is likely due to SQLite not having a native GUID type, which means that GUID values are saved, if I remember correctly, as blobs. The sorting is thus done on these blobs, which I am guessing gives a different order to the natural ordering of GUIDs. |
From the docs:
...and the other docs:
|
So this isn't a bug and actually correct implementation? Is it correct and intended that using a different database type (e.g. UseInMemoryDatabase(...)) Gives a different result? |
@chris31389 Sorting order is one of those things that can be different between the CLR and the database, and between different databases, especially, but not exclusively, when values have different representations. We're currently in the middle of discussions on ways to handle this, but it may be that it is inherently something that can vary between database providers. |
Reopening so that we can decide on this particular issue as port of the larger discussion (i.e. I am not sure leaving it like it is now is the best outcome). |
@ajcvickers I've just tested this with SqlServer and its producing the same results. Should I raise a new issue? |
@chris31389 Thanks for the info. It does indeed seem that the default ordering for GUIDs on .NET is different from that of SQL Server. No need for another issue--I have added a note to #10265 which is the general issue we have for consideration of this issue. |
I'm trying to order by a Guid in EF Core with a relational database and its not ordering. Is there something I'm doing wrong or could this be an issue with EF Core?
Steps to reproduce
Using NUnit I created the following test
Further technical details
EF Core version: EF core 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: Windows 10
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: