How to Convert List<T> to BsonArray to save a MongoDB Document
<p>I'm having an Model Class, I need to Save it in a MongoDB Collection.</p>

<p>My Model Class:</p>

<pre><code>public Class Employee
{
    public string EmpID { get; set; }
    public string EmpName { get; set; }
    public List&lt;Mobile&gt; EmpMobile { get; set; }
}

public Class Mobile
{
    public string MobID { get; set; }
    public string MobNumber { get; set; }
    public bool IsPreferred { get; set; }
}
</code></pre>

<p>The Values are</p>

<pre><code>Employee EmpInfo = new Employee()
{
    EmpID = "100",
    EmpName = "John",
    EmpMobile = new List&lt;Mobile&gt;()
    {
        { MobNumber = "55566610", IsPreferred = true },
        { MobNumber = "55566611", IsPreferred = false },
    }
}

BsonDocument _employee = new BsonDocument()
                             {
                                 { "Emp_ID", EmpInfo.EmpID },
                                 { "Emp_Name", EmpInfo.EmpName },
                                 { "Emp_Mobile", new BsonArray (EmpInfo.EmpMobile.Select(m =&gt; new 
                                     {
                                         MobID = new ObjectId(),
                                         MobNumber = m.MobNumber,
                                         IsPreferred = m.IsPreferred
                                     })) }
                             };

var collection = _database.GetCollection&lt;BsonDocument&gt;("EmployeeInfo");
collection.InsertOne(_employee);
</code></pre>

<p>I wish to save the above <strong><code>EmpInfo</code></strong> of type <strong><code>Employee</code></strong> in a MongoDB. But I can't able to create a BsonDocument. Kindly assist me is there is anything wrong in the above code. If yes kindly assist me.</p>