We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
CREATE TABLE default.Sum ( id Int32, Total UInt32, -- payment amount *100 ) ENGINE = MergeTree PRIMARY KEY (Clinic_id); INSERT INTO default.Sum (1, 11000);
The following query returns the correct data:
SELECT id, divide(toDecimal32(Total, 2), 100) AS total, toTypeName(toDecimal32(Total, 2), 100) AS type_name FROM default.Sum; |id|total |type_name | +--+-------+-------------+ | 1| 110.00|Decimal(9, 2)|
But when converting data in the NET app, an error occurs.
var Total = row.Field<decimal>("total");
System.InvalidCastException: "The specified cast is not valid."
Converting on the Clickhouse side to other toDecimal64 and toDecimal128 types didn't help either.
Only such a code turned out to be working
var Total = Convert.ToDecimal(row.Field<object>("total"));
But I would like to receive data without double type conversion. Or am I doing something wrong?
The text was updated successfully, but these errors were encountered:
It is ClickHouseDecimal by default, so you can use the explicit conversion operator:
ClickHouseDecimal
var total = (decimal) row.Field<ClickHouseDecimal>("total")
If you want it to be a .Net decimal in the DataTable, you should add UseCustomDecimals=false to the connection string.
DataTable
UseCustomDecimals=false
@DarkWanderer it is said in the wiki that UseCustomDecimals is false if omitted, but it seems to be true (link).
UseCustomDecimals
false
true
Sorry, something went wrong.
No branches or pull requests
The following query returns the correct data:
But when converting data in the NET app, an error occurs.
System.InvalidCastException: "The specified cast is not valid."
Converting on the Clickhouse side to other toDecimal64 and toDecimal128 types didn't help either.
Only such a code turned out to be working
But I would like to receive data without double type conversion. Or am I doing something wrong?
The text was updated successfully, but these errors were encountered: