title: Unable to insert file stream into SQL filetable using Dapper.NET
body: <p>I am using Dapper.NET as ORM layer in my project. I am trying to write WebApis for  file upload and download. However I am not able to get it working. I have already searched enough to look for help but I couldn't find any.</p>
  
  <p>If I was simply using ADO.NET, I could have used SqlParameter of type VarBinary for the file stream. But Dapper.NET query parameters is just dynamic object. So following code fails to insert the record into filetable.</p>
  
  <pre><code>var fileStream = await Request.Content.ReadAsStreamAsync();
  
  var streamId = Guid.NewGuid();
  var fileName = streamId.ToString();
  
  var sql = @"Insert into Attachments(stream_id, file_stream, name)
              Values(@streamId, @fileStream, @fileName)";
  
  using (var db = new SqlConnection(AppConfig.ConnectionString))
  {
      await db.ExecuteAsync(sql, new { streamId, fileStream, fileName);
  }
  
  fileStream.Close();
  </code></pre>
  
  <blockquote>
    <p>Exception thrown: 'System.NotSupportedException' in mscorlib.dll</p>
    
    <p>Additional information: The member fileStream of type System.IO.Stream
    cannot be used as a parameter value</p>
  </blockquote>
  
  <p>Has anyone done this or be aware of any dapper extension plugin I could use?</p>