title: Converting varbinary to image
body: <p>I managed to convert an Image to a varbinary and store it in my database. I have been trying to convert the varbinary to an Image but I'm running in some trouble here.</p>
  
  <p>First I get the Binary from my database in my service.</p>
  
  <pre><code>    public Binary getAfbeelding(int id)
      {
  
          var query = (from p in dc.Afbeeldings
                       where p.id == id
                       select p.source).Single();
  
          Binary source = query;
          return source;
      }
  </code></pre>
  
  <p>Then I try to convert the varbinary to an image, using code found on StackOverflow: </p>
  
  <pre><code>    public static string convertToImage(Binary source)
      {
          byte[] b = source.ToArray();
          MemoryStream ms = new MemoryStream(b);
          Image img = Image.FromStream(ms);
          return img.Source.ToString();
      }
  </code></pre>
  
  <p>I am running into trouble before the call to <code>new MemoryStream</code> :</p>
  
  <blockquote>
    <p>'OndernemersAward.EditAfbeeldingServiceReference.Binary' does not contain a definition for 'ToArray' and no extension method 'ToArray' accepting a first argument of type
        'OndernemersAward.EditAfbeeldingServiceReference.Binary' could be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>For some weird reason, I CANNOT use the 'normal' Binary, it will ALWAYS tell me to use <code>OndernemersAward.EditAfbeeldingServiceReference.Binary</code> which is my ServiceReference, as you can see.</p>
  
  <p>How can this be solved?</p>