In Entity Framework, mapping from Byte[] Property annotated with @MaxLength() to (Tiny|Medium|Large)Blob is not right
Posted by: Emiliano Marino
Date: September 02, 2016 08:41AM

Sorry my lack of knowlegde on mysql connector source code... i'm just a user of the library.

I'm trying to map a property in .net whose type is Byte[]. I need to write files around 500k in size. Clearly a Blob doesn't do the job, so next step is mediumblob. But when I let Entity Framework do the table creation, it creates the field as BLOB. Googling around I found a piece of code that explain that bad behavior...

if (maxLength < CHAR_MAXLEN) typeName = "tinyblob";
else if (maxLength < MEDIUMBLOB_MAXLEN) typeName = "blob";
else if (maxLength < LONGTEXT_MAXLEN) typeName = "mediumblob";
else typeName = "longblob";

This code was found in this file:
mysql-connector-net/Source/MySql.Data.EntityFramework5/ProviderManifest.cs

As you can see logic is wrong... is maxLength is 500000 the 'if' conclude with 'blob'.
I think this is the correct logic...

if (maxLength > MEDIUMBLOB_MAXLEN) typeName = "longblob";
else if (maxLength > VARBINARY_MAXLEN) typeName = "mediumblob";
else if (maxLength > CHAR_MAXLEN) typeName = "blob";
else typeName = "tinyblob";


But I don't have the experience to get connector.net compiling in my machine.
Thanks!

Options: ReplyQuote


Subject
Written By
Posted
In Entity Framework, mapping from Byte[] Property annotated with @MaxLength() to (Tiny|Medium|Large)Blob is not right
September 02, 2016 08:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.