title: C# MongoDB Driver: Querying Array of Authors for partial or complete match on author full name
body: <p>I'm using the MongoDB C# Driver version <code>2.11.0</code> to query against a collection of Book documents.</p>
  <p>This is what the book model looks like, reduced to include only fields of interest:</p>
  <pre><code>public class Book
  {
      public string Title { get; set;}
      public List&lt;Author&gt; Author { get; set; }
      # bunch of other fields
  }
  
  public class Author
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
  
  }
  </code></pre>
  <p>Given an author</p>
  <pre><code>{
      FirstName: &quot;Mary&quot;,
      LastName: &quot;Doe
  }
  </code></pre>
  <p>I'm trying to write a query that will return all matches whether the author search criteria is <code>Mary</code>, <code>Doe</code>, or <code>Mary Doe</code>.</p>
  <p>I have something like this:</p>
  <pre><code>var searchValue = &quot;Mary Doe&quot;;
  var regex  = new Regex(searchValue, RegexOptions.IgnoreCase);
  
  var results = booksCollection.AsQueryable&lt;Book&gt;()
                .Where(book =&gt;
                   book.Author.Any(author =&gt;
                     regex.isMatch(author.FirstName) ||
                     regex.isMatch(author.LastName)
                   )
                );
  
  </code></pre>
  <p>which works when searching for <code>Mary</code> or <code>Doe</code>, but not <code>Mary Doe</code>.
  How can I get this to work? I have tried adding</p>
  <pre><code>regex.isMatch($&quot;{author.FirstName} {author.LastName}&quot;)
  </code></pre>
  <p>as a third condition, but that causes the driver to throw an <code>InvalidOperationException</code>.
  <a href="https://i.stack.imgur.com/OK2zn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OK2zn.png" alt="" /></a></p>