The .NET SqlClient throws this Exception an when trying to call IDataReader.GetValues() when a record contains a Max Decimal:
at System.Data.SqlClient.SqlBuffer.get_Decimal()
at System.Data.SqlClient.SqlBuffer.get_Value()
at System.Data.SqlClient.SqlDataReader.GetValues(Object[] values)
at ServiceStack.OrmLite.OrmLiteDialectProviderBase`1.GetValues(IDataReader reader, Object[] values)
at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.PopulateWithSqlReader[T](T objWithProperties, IOrmLiteDialectProvider dialectProvider, IDataReader reader, Tuple`3[] indexCache, Object[] values)
So OrmLite then falls back to perform individual column fetches which throws the same Exception:
at System.Data.SqlClient.SqlBuffer.get_Decimal()
at System.Data.SqlClient.SqlBuffer.get_Value()
at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)
at ServiceStack.OrmLite.OrmLiteConverter.GetValue(IDataReader reader, Int32 columnIndex, Object[] values)
at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.PopulateWithSqlReader[T](T objWithProperties, IOrmLiteDialectProvider dialectProvider, IDataReader reader, Tuple`3[] indexCache, Object[] values)
Basically doesn’t look like .NET’s SqlClient can read a max decimal value.
I used decimal as Microsoft suggests.
Does SQL Server decimal datatype is incompatible with .net?
It sounds like Microsoft is incompatible with itself.
Postgres is completely unrelated because it’s using a different npgsql ADO.NET Provider, SQL Server uses the .NET SqlClient to communicate with SQL Server.
Does OrmLite can cope with this issue?
OrmLite is physically unable to read the value from SQL Server’s ADO.NET Provider.
The exception occurred in OrmLite which by default swallows data read exceptions and logs it instead in order to return as much data as possible. So it would be visible if you had logging enabled.
I’ve just added an option where you can get OrmLite to throw on Exceptions like this in this commit with:
OrmLiteConfig.ThrowOnError = true;
This change is available from v4.5.9 that’s now available on MyGet