0

First of all, sorry for the probable English mistakes

I created a table in my postgresql database using the entity framework.

In edmx in the creation section I passed as bytea, however in the mapping I used binary (primitive type use is necessary).

<EntityType Name="styleexample">
      <Key>
        <PropertyRef Name="id" />
      </Key>
      <Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
      <Property Name="example" Type="String" MaxLength="40" />
      <Property Name="example1" Type="Binary" />
      <Property Name="example2" Type="DateTime" />
</EntityType>

<EntityType Name="styleexample">
      <Key>
        <PropertyRef Name="id" />
      </Key>
      <Property Name="id" Type="int4" StoreGeneratedPattern="Identity" Nullable="false" />
      <Property Name="example" Type="varchar" MaxLength="40" />
      <Property Name="example1" Type="bytea" />
      <Property Name="example2" Type="timestamp" />
</EntityType>

The table was created with the correct typing

column

In the entity I referenced the column as byte []

entities

In the column I inserted the base64 string of a png image, but in the service when I return the value is different from what I inserted

execute the query in the database

My response is also byte[]

It works. However, it returns the incorrect value. Is there a different way to do this process?

mribeiro
  • 197
  • 11

1 Answers1

0

I solved the issue by adding to the service

var example1 = new StreamReader(new MemoryStream(estilo.example1));
var example1Stream = example1 .ReadToEnd();
mribeiro
  • 197
  • 11