title: Serializing simple ASP.Net Object with Byte Array to Bson, C# wrapper
body: <p>I have a simple ASP.Net Object to collect file information for storage in Mongo.  The FileAttrib class is already populated.</p>
  
  <pre><code>public class FileAttrib
  {
      public string Filename { get; set; }
      public long FileSize { get; set; }
      public string FileContent { get; set; }
      public string FileType { get; set; }
      public byte[] FileContents { get; set; }   
  }
  </code></pre>
  
  <p>I have tried several iterations of serializing this object to Bson with no luck.  It seems simple enough but I am missing something.</p>
  
  <pre><code>public async void AddDocumentToMongo(string db, FileAttrib fa)
  {
      _client = MongoDbConnection.GetMongoClient();
      _database = MongoDbConnection.GetMongoDatabase(_client, db);
      var collection = _database.GetCollection&lt;FileAttrib&gt;("testInsert");
  
      var doc = BsonDocument.Create(fa);
  
      await collection.InsertOneAsync(doc);
  }
  </code></pre>
  
  <p>The error is created in the BsonDocumentCreate Statement:{".NET type FileUpload.Models.FileAttrib cannot be mapped to BsonType.Document.\r\nParameter name: value"}</p>
  
  <p>I'm not sure what this means but I think it must be fairly simple to solve - I'm just not getting it right now.</p>