I am receiving an exception “Unable to cast object of type ‘System.Byte[]’ to type ‘System.IConvertible’” when i try to insert a bytea on postgres from c#.
I am trying to insert an image from a byte[] with devexpress utils:
o.image_bytea = ByteImageConverter.ToByteArray(image, ByteImageConverter.GetImageFormatByPixelFormat(image));
On schema modeler this field is of type “Blob”.
Stacktrace:
in System.Convert.ToDateTime(Object value)
in RemObjects.DataAbstract.Bin2StreamWriter.WriteVariant(Object value, DataType dataType)
in RemObjects.DataAbstract.Bin2DataStreamer.InternalWriteDelta(Delta delta, Boolean dynamicSelect)
in RemObjects.DataAbstract.DataStreamer.WriteDelta(Delta delta, Boolean dynamicSelect)
in RemObjects.DataAbstract.Linq.LinqRemoteDataAdapter.InternalUpdate(Delta[] deltas)
in RemObjects.DataAbstract.Linq.LinqDataAdapter.ApplyChanges()…
in System.Convert.ToDateTime(Object value)
in RemObjects.DataAbstract.Bin2StreamWriter.WriteVariant(Object value, DataType dataType)
Could you create a testcase for this issue? It seems to be specific for your fields / request/ data combination, so it would be the best way to pinpoint it. Please send it ot support@ and we’ll keep it private.
I’ve reproduced the issue. A workaround if to add this attribute to the defnition of the datetime_created field:
[RemObjects.DataAbstract.Linq.LogChanges()]
This will resolve the issue. I’ll log it to perform further investigation to determine was it a Data Abstract bug or an error in the Schema definition.
at NpgsqlTypes.NpgsqlTimeStampTZ.op_Explicit(NpgsqlTimeStampTZ timestamp)
at NpgsqlTypes.NpgsqlTypesHelper.b__10(Object timestamptz)
at NpgsqlTypes.NpgsqlBackendTypeInfo.ConvertToFrameworkType(Object providerValue)
at Npgsql.ForwardsOnlyDataReader.GetValue(Int32 Index)
at Npgsql.NpgsqlDataReader.get_Item(Int32 i)
This is acrash deep inside the ADO.NET driver. It was unable to convert a value read from the database.