Projection in Where Clause Query of a Embedded document in MongoDB Collection using C#
<blockquote>
  <p>Filter the Collection in DB instead of Memory</p>
</blockquote>

<p>I'm having a Model Class, Save it in a MongoDB Collection then Query the same as per my expectation mentioned below.</p>

<p>My Model Class:</p>

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

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

<p>The Values are</p>

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

new Employee()
{
    EmpID = "101",
    EmpName = "Peter",
    EmpMobile = new List&lt;Mobile&gt;()
    {
        new Mobile() { MobNumber = "55566610", IsPreferred = true, IsLive = false },
        new Mobile() { MobNumber = "55566611", IsPreferred = false, IsLive = false },
    },
    IsLive = true
},

new Employee()
{
    EmpID = "102",
    EmpName = "Jack",
    EmpMobile = new List&lt;Mobile&gt;()
    {
        new Mobile() { MobNumber = "55566610", IsPreferred = true, IsLive = true },
        new Mobile() { MobNumber = "55566611", IsPreferred = false, IsLive = true },
    },
    IsLive = false
}

}

collectionEmpInfo.InsertMany(EmpInfo);
var empList = collectionEmpInfo.Find(new BsonDocument()).ToList();
</code></pre>

<p>Now I wish to Select Only <strong><code>EmpInfo.IsLive == true</code></strong> inside the embedded document I need only <strong><code>EmpInfo.EmpMobile.IsLive == true</code></strong> satisfied Mobile documents</p>

<p>My Expected Output:</p>

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

new Employee()
{
    EmpID = "101",
    EmpName = "Peter",
    EmpMobile = new List&lt;Mobile&gt;()
    {

    },
    IsLive = true
}

}
</code></pre>

<p>Kindly assist me how to write a <strong>Where Clause Query</strong> for my expected output using <strong>c# MongoDB</strong>.</p>

<blockquote>
  <p><strong>Note:</strong> Filter the Collection in DB instead of Memory</p>
</blockquote>

<p>My MongoDB Libraries and Connections are</p>

<pre><code>IMongoClient _client = new MongoClient();
IMongoDatabase _database = _client.GetDatabase("Test");
</code></pre>