title: Detect if a list has ANY attachment in SharePoint CSOM
body: <p>I need to read all items from a SharePoint-list including all attachments. This is the code:</p>
  
  <pre><code>foreach (var item in allItems)
  {
     Dictionary&lt;string, string&gt; itemFilenames = GetFilenames(item.Id);
     if (itemFilenames != null &amp;&amp; itemFilenames.Count &gt; 0)
     {
        // [...]
     }    
  }
  private AttachmentCollection GetFilenames(id) { 
    List list=_context.Web.GetListByTitle("mylist");
    ListItem=list.GetItemById(id);
    var files=item.AttachmentFiles;
    _context.Load(files);
    _context.ExecuteQuery();
    return files;
  }
  </code></pre>
  
  <p>Now 90% of my lists do not contain any attachments at all. Still: I try to retrieve the attachments for every single item which slows down the program massively.</p>
  
  <p>So my idea would be to detect if the list has ANY attachment at all before trying to retrieve those for each item. So something like that:</p>
  
  <pre><code>var list=clientContext.Web.GetListByTitle("mylist");
  if (!list.ContainsAttachments) return; // &lt;-- What I want to do
  foreach (var item in allItems) { ... }
  </code></pre>
  
  <p>Of course, the "if" - statement does not really work that way. But is there another method to find out if any attachment exists that would result in the wanted behavior?</p>
  
  <p><strong>TL;DR:</strong> I want to know if a list contains ANY attachment without looping through every item of that list</p>