title: How to query sub document (list type) in Cosmos Db
body: <p>I have a collection in Azure CosmosDB, and each document looks like this:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
    "id": "random",
    "TeacherName": "Ben",
    "Students": [
      {
        "Name": "John",
        "Telephone": ""
      },
      {
        "Name": "Mary",
        "Telephone": ""
      }
    ],
  }
  </code></pre>
  
  <p>TeacherName is string, Students is a list of student</p>
  
  <p>I need to do: Given a user name (user1), query and return all the documents, either teacher name is "user1" or there is a student with name "user1". </p>
  
  <p>I tried a few options, but cannot do it. </p>
  
  <p>The closest solution I found so far is to use <code>.SelectMany()</code>, but I found <code>.SelectMany</code> will do a join and will duplicate the return results.</p>
  
  <p>This is my query:</p>
  
  <pre><code>client.CreateDocumentQuery().SelectMany((x) =&gt; x.Students.Where(s=&gt;s.Name == "user1" || x.TeacherName == "user1")   
  </code></pre>
  
  <p>If only the above sample document in the collection, and when I searched user name "Ben", 2 records will be returned ((number of result) * (number of students)). I have to remove the duplicate at client side and pagination is kind of broken.</p>
  
  <p>Is it possible to issue a single query to achieve what I need?</p>