Warning: Invalid argument supplied for foreach() in D:\home\site\wwwroot\wp-includes\translations.php on line 1174 Warning: Invalid argument supplied for foreach() in D:\home\site\wwwroot\wp-includes\translations.php on line 1367

How to build a Lucene query using extension methods, and not have the request go out until ToList() is called.

private List GetMembers(string nickname)
{
  var query = DocumentSession.Advanced.LuceneQuery(AllMembersIndex.Name);
  
  // Search for nickname
  if (!nickname.IsNullOrWhiteSpace())
    query = query.Search("Nickname", nickname);
  
  // Execute query
  return query.ToList();
}