title: Store and retrieve binary image in WPF
body: <p>I have saved Image in database as binary :</p>
  
  <pre><code> Microsoft.Win32.OpenFileDialog fd = new Microsoft.Win32.OpenFileDialog();
          if (fd.ShowDialog() == true)
          {
              ILogo.Source = new BitmapImage(new Uri(fd.FileName));
  
              Stream stream = File.OpenRead(fd.FileName);
              binaryImage = new byte[stream.Length];
              stream.Read(binaryImage, 0, (int)stream.Length);
          }
             _merchantInfo.Logo = binaryImage;
  </code></pre>
  
  <p>I want to read the image and showing it image tool, I tried this:</p>
  
  <pre><code>        _merchantInfo = new MerchantInfo();
          _merchantInfo = _context.MerchantInfo.FirstOrDefault();
  
          byte[] binaryPhoto = (byte[])_merchantInfo.Logo;
          Stream stream = new MemoryStream(binaryPhoto);
          _merchantLogo = new BitmapImage();
          _merchantLogo.StreamSource = stream;
  
          ILogo.Source = _merchantLogo;
  </code></pre>
  
  <p>No Error, But the image does not showing in image box :(</p>
  
  <p>Is there error in my code?</p>
  
  <p>Thanks.</p>