title: SharePoint Online: Get Document Library Children Count Using CSOM
body: <p>My requirement is to get the children item count of Document Library using CSOM. The count should only be the immediate children count, and should not include the sub-children count. I am trying to use below code to achieve this:</p>
  
  <pre><code>var newObjClientContext = this.GetSharePointClientContext(accessToken, fullUri);
  WebCollection collWeb = newObjClientContext.Web.GetSubwebsForCurrentUser(new SubwebQuery());
  var documentLibrary = newObjClientContext.Web.Lists.GetById(docID);
  
  ListItemCollection ltitems = null;
  
  string vquery = @"&lt;View &gt;
                  &lt;Query&gt;
                      &lt;Where&gt; 
                          &lt;Or&gt; 
                              &lt;Eq&gt;
                                  &lt;FieldRef Name='FSObjType' /&gt; 
                                  &lt;Value Type='Lookup'&gt;1&lt;/Value&gt;
                              &lt;/Eq&gt; 
                              &lt;Eq&gt;
                                  &lt;FieldRef Name='FSObjType' /&gt; 
                                  &lt;Value Type='Lookup'&gt;0&lt;/Value&gt;
                              &lt;/Eq&gt; 
                              &lt;/Or&gt; 
                          &lt;/Where&gt;
                          &lt;OrderBy&gt;&lt;FieldRef Name='FileLeafRef' Ascending='TRUE'&gt;&lt;/FieldRef&gt;&lt;/OrderBy&gt;                                        
                      &lt;/Query&gt;
                      &lt;RowLimit&gt;" + recCount + @"&lt;/RowLimit&gt;
                      &lt;/View&gt;";
  
  CamlQuery camlQuery = new CamlQuery();
  
  camlQuery.ViewXml = vquery;
  ltitems = documentLibrary.GetItems(camlQuery);
  newObjClientContext.Load(documentLibrary);
  newObjClientContext.Load(ltitems, lists =&gt; lists.IncludeWithDefaultProperties(l =&gt; l.ParentList));
  
  newObjClientContext.ExecuteQuery();
  
  int totalcount = documentLibrary.ItemCount; //It includes count of all the items present at all levels.
  </code></pre>
  
  <p>Can anyone suggest how can I get children count in above step?</p>