Postgres bytea problem

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()…

Is there something wrong?

Well, something is really wrong here:

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.

Thanks for the testcase.

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.

Regards

Thanks, logged as bugs://78750

bugs://78750 got closed with status fixed.

The fix should be already available in the Beta build

Can this error be related to same problem?

var result =
from o
in DataAdapter.GetTable<generic_piece>()
orderby o.id descending
select o;

Si è verificata l’eccezione RemObjects.SDK.Types.ServerException
HResult=0x80131500
Messaggio=An exception occurred on the server: Specified cast is not valid.
Origine= 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)
at RemObjects.DataAbstract.Server.Sql.QueryProcessor.VisitSelect(SelectAction action)
at RemObjects.DataAbstract.Server.Sql.ActionVisitor.Visit(DASqlAction action)
at RemObjects.DataAbstract.Server.Sql.DASqlProcessor.GetData(String tableName, String sql, WhereExpression additionalWhere, DataParameter[] parameters, IAbstractConnection connection, ServiceSchema serviceSchema, DataStreamer streamer, Int32 maxRecords, Boolean allowPrivateAccess)
at RemObjects.DataAbstract.Server.DataAbstractService.GetDataViaDASql(String tableName, TableRequestInfoV6 requestInfo, DataStreamer streamer, Boolean allowPrivateAccess)
at RemObjects.DataAbstract.Server.DataAbstractService.InternalGetData(String[] tableNames, TableRequestInfo[] requestInfo, DataStreamer streamer, Boolean allowPrivateAccess)
at RemObjects.DataAbstract.Server.DataAbstractService.GetData(String[] tableNames, TableRequestInfo[] requestInfo)
at RemObjects.DataAbstract.Server.DataAbstractService_Invoker.Invoke_GetData(IROService __Instance, IMessage __Message, IServerChannelInfo __ServerChannelInfo, ResponseOptions& __oResponseOptions)
at RemObjects.SDK.Server.ServerChannel.InvokeMethod(IMessage message, IServerChannelInfo channel, ServiceInfo info)
at RemObjects.SDK.Server.ServerChannel.InvokeService(IMessage message, IServerChannelInfo channel)

No

Take a closer look at the stacktrace:

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.