title: How can convert byte data to String with EntityFramework
body: <p>I have a web service in .NET. With this ws, I can receive the image in Base64, I stored it into my database throught Entity Framework. To do this, I convert this String in Byte. With this code:</p>
  
  <pre><code>    static byte[] GetBytes(string str)
      {
          byte[] bytes = new byte[str.Length * sizeof(char)];
          System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
          return bytes;
      }
  </code></pre>
  
  <p>Now, I must get this data from database and show it from ws. So I have this code to retreive the data and print the response:</p>
  
  <pre><code>private IQueryable&lt;ImmaginiSecSocDTO&gt; getSecSocData(int? id)
  {
      if (id != null)
      {
      return from u in db_data.CAMERA_SEC_SOC 
             where u.ID == id
             select new ImmaginiSecSocDTO()
             {
             image = System.Text.Encoding.UTF8.GetString(u.Image),
             image_width = u.image_width,
             image_height= u.image_height,
             type = u.type,
             rectangle = new ImmaginiSecSocDTO.Rectangle()
             {
               rects = from pi in db_data.CAMERA_SEC_SOC_Rectangles 
                  where pi.ID_SecSoc  == id
                  select new ImmaginiSecSocDTO.Rectangle.Rect()
                  {   
                  height= pi.height,
                  width = pi.width,
                  x = pi.x,
                  y=pi.y
                  }
             } 
             };
      }
      return null;
  }
  </code></pre>
  
  <p>But if I try to run it I receive this error message:</p>
  
  <blockquote>
    <p>"ExceptionType": "System.NotSupportedException",
        "StackTrace": "   in System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.DefaultTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)\r\n   in System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)\r\n   in System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)\r\n   in System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)\r\n</p>
  </blockquote>