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
Using wrong type for blob [DNET876] #806
Comments
Commented by: @cincuranet The table on latest providers gets this definition: Which is correct. Even the query is different: Can you provide reproducible test code? |
Modified by: @cincuranetstatus: Open [ 1 ] => In Progress [ 3 ] |
Commented by: Vladimir Karataev (vladimir karataev) Provider work fine with SUB_TYPE BINARY, and map on byte[] type in c# code. I found workaround: db.Test.FromSql("...cast(raw_Data as blob sub_type 0)...") An sad moments in such case. Entity generate query like "select from select". And interesting moment. On UPDATE query byte[] mapping on BLOB SUB_TYPE 1 perfect. Only SELECT query make wrong mapping BLOB SUB_TYPE 1 to string, but not to byte[]. |
Commented by: @cincuranet SUB_TYPE 1 is text/string. Doesn't make sense with byte[]. The rest I don't understand. Unless I see some simple failing code, there's not much I can do. |
Commented by: Vladimir Karataev (vladimir karataev) Why all operations with blob sub_type 1 as byte[] work fine, and only select is wrong? If SUB_TYPE 1 = text/string, than all operations should work with blob as string. An other hand, If SUB_TYPE 1 may be as byte[], than all oprations should work with blob as byte[]. Now I demonstrate mixed behavior with blob sub_type 1, when in some operations i can use byte[], and in select i can't use byte[]. Demo was be attached to ticket. |
Modified by: Vladimir Karataev (vladimir karataev)Attachment: ConsoleApp1.7z [ 13338 ] |
Commented by: @cincuranet Your mapping is wrong. You have the column as "BLOB SUB_TYPE 1", which is expected to be string. If you want to use "byte[]", use sub type 0. |
Submitted by: Vladimir Karataev (vladimir karataev)
Attachments:
ConsoleApp1.7z
I am using next data model:
[Table("table")]
public class Test
{
[Key][Required]
public long Id {get; set; }
[Column("raw_data")]
public byte[] raw_data {get; set; }
}
The column "raw_data" was descripted as: BLOB SUB_TYPE 1 SEGMENT SIZE 100 CHARACTER SET UTF8;
This is a BLOB.
I execute request of data from table through entity framework:
var data = db.Test.Find(id);
In window trace into visual studio i watch query:
SELECT "e"."ID", "e"."RAW_DATA" FROM "TABLE" AS "e" WHERE "e"."ID" = CAST(@__get_Item_0 AS BIGINT)
I have got exception in this place:
"Unable to cast object of type 'System.String' to type 'System.Byte[]'."
I suppose, provider should be using blob type for this column, but it using type of string for this column. May be it wrong behavior?
The text was updated successfully, but these errors were encountered: