MariaDB longblob

15 posts, 0 answers
  1. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 19 Sep 2014 Link to this post

    Hi,

    I am trying to setup a MariaDB database with Data Access.

    One of the requirements is for Blob support.

    I have a field in the database with a type of longblob, I believe I should be setting the corresponding .NET type to byte[] and have done so.

    This compiles correctly but when I try to access the field I get the following error:


      HResult=-2146233088
      Message=The metadata for field '_content' of class 'ProfileModel.File' cannot be initialized: Type converter initialization failed. The converter with name 'OpenAccessRuntime.Data.Blob2BlobConverter' does not convert from CLR type 'System.Byte[]' to SQL type 'longblob'.
    Parameter name: converterName
    Actual value was OpenAccessRuntime.Data.Blob2BlobConverter.
     
    Do I have things correct for Blobs in MariaDB and if yes how do I fix the above error?

    TIA

    Nic
  2. Ady
    Admin
    Ady avatar
    588 posts

    Posted 19 Sep 2014 Link to this post

    Hello Nic,

     You should use the 'BinaryStream' type to read blob fields. Following are some links on how to handle blob database fields by using streams.
    1. Working with streams
    2. Working with BinaryStream type

     Do get back in case you need further assistance.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 22 Sep 2014 in reply to Ady Link to this post

    Hi Ady,

    I guess I'm hazy on the BinaryStream type. I don't see "BinaryStream" in the "type" dropdown for a field and if I choose 'Stream' I get another error:

    Error 1 The CLR type (Stream) for member with name 'Content' of the 'File' persistent class is not a valid mapping for the selected column with SQL type longblob.

    I've tried using the "Blob" CLR type but that does not seem to be initialised.

    Where am I going wrong?

    Thanks

    Nic
  5. Ady
    Admin
    Ady avatar
    588 posts

    Posted 25 Sep 2014 Link to this post

    Hello Nic,

     I will prepare an example and reply back.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  6. Ady
    Admin
    Ady avatar
    588 posts

    Posted 02 Oct 2014 Link to this post

    Hi Nic,

     I have prepared an example that demonstrates the usage of BinaryStream to read and write data to a longblob column in a MariaDB database. 
    This example uses fluent mapping to map the model but it should work the same with the domain model also.

    Do have a look and get back in case you have any questions.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  7. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 09 Oct 2014 in reply to Ady Link to this post

    Hi Ady,

    Thanks for the sample. As far as I can make out you are defining the column mapping from a MariaDB longblob to a Stream (at least that is how it looks to me in the Blobtest class). However when I use the model tool I do not have a binary stream field type to choose and if I try to use stream I get the following error:

    Error 1 The CLR type (Stream) for member with name 'Content' of the 'File' persistent class is not a valid mapping for the selected column with SQL type longblob.

    Would it be possible for you to explain or provide an example of how to handle blobs using the model first approach? I understand how to get the data in and out of the column I just don't seem to be able to configure the mapping of the column using the mapping.

    Thanks for your patience,

    Nic
  8. Ady
    Admin
    Ady avatar
    588 posts

    Posted 14 Oct 2014 Link to this post

    Hi Nic,

     I have prepared a similar sample but with the Model first approach. The class has  a 'Stream' property that is mapped to a 'longblob' column.

    Do have a look at the example and get back in case you have any questions.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  9. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 17 Oct 2014 in reply to Ady Link to this post

    Hi Ady,

    Thanks for the model first sample but I get the same error when I try to compile your sample:

    Error 1 The CLR type (Stream) for member with name 'BlobField' of the 'TestClass' persistent class is not a valid mapping for the selected column with SQL type longblob. C:\Users\nica\Desktop\MariaDBStreamExample\ConsoleApplication1\EntitiesModel1.rlinq 0 0 

    Nic
  10. Ady
    Admin
    Ady avatar
    588 posts

    Posted 20 Oct 2014 Link to this post

    Hello Nic,

     This is indeed strange. Are you sure you are using version 2014.2.711 of the product? Can you update to the latest version of the product and try again?

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  11. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 21 Oct 2014 in reply to Ady Link to this post

    Hi Ady,

    Data access is reporting itself as 2014.2.918.1

    Nic
  12. Ady
    Admin
    Ady avatar
    588 posts

    Posted 23 Oct 2014 Link to this post

    Hello Nic,

     Can you try uninstalling and reinstalling the product? 

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  13. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 03 Nov 2014 in reply to Ady Link to this post

    Hi Ady,

    Sorry for the delay in replying - I took a few days vacation.

    I've uninstalled and reinstalled all my Telerik products. This has moved my DA version up to 2014.3.102. I still have the same error when attempting to compile your stream example.

    Nic
  14. Ady
    Admin
    Ady avatar
    588 posts

    Posted 06 Nov 2014 Link to this post

    Hello Nic,

     I suspect this might be an error reported by the designer.Can you nevertheless try to run the example(F5 or ctrl+F5)? Errors reported by the designer are ignored by the compiler.
    If that does not work can you try creating a fresh console application and add a model to it and create an entity with a Stream field?
    I could successfully compile the sample on a clean machine with DataAccess version 2014.2.711.1 installed and hence have no clue at the moment why you cannot compile.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  15. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 07 Nov 2014 in reply to Ady Link to this post

    Hi Ady,

    Sorry perhaps I should have been clearer that this is a designer error. The program does compile and run.

    Nic
  16. Ady
    Admin
    Ady avatar
    588 posts

    Posted 10 Nov 2014 Link to this post

    Hi Nic,

     Glad to know that is works. 
    Do get back in case you need further assistance.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top
DevCraft banner