-
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 orderby decimal column #10249
Comments
SQLite stores decimal as Text, The ordering on database would sort strings rather than decimal values. |
Correct. SQLite doesn't natively support |
Should line 58 be replaced with the line below? { typeof(decimal), new DecimalTypeMapping(_realTypeName) }, |
No, converting from |
Would using a |
My proposal was to use |
Would that result in casting in the underlying query? I'm working with a money value and heard that decimal was better to use for money values than a double? |
@chris31389 SQLite can't store decimal values natively. This means that, in the general case, using SQLite to store things like monetary values will always have some limitations. As @bricelam said, usually storing the exact values (non-lossy) is more important than preserving store-side sort order. It's probably safe to do the conversion to doubles in the query, as shown above, because even if this is lossy, it is unlikely to impact sort order. If it will, then the only option is to bring the data back to the client and sort it there. I have filed #10265 for us to track future work in this area. For now, closing this as by-design. |
I have a class with a decimal property. I wanted to order all instances of the class by the decimal property within the SQLite database.
I created three instances with these decimal values
{ 7m, 84.3m, 13.4m }
. After running anOrderBy
function, I expected it to order it to{ 7m, 13.4m, 84.3m }
but instead it ordered it to{ 13.4m, 7m, 84.3m }
Steps to reproduce
Please run the test below
Further technical details
EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: Windows 10 64x
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: