LINQ - exclude the filter when the value is NULL
<p>I am trying to see if there is any better way of writing the query below when there is an optional parameter (CountryId) which can be NULL</p>

<pre><code> public static IEnumerable&lt;Game&gt; GameByMatchingName(this IRepositoryAsync&lt;Game&gt; repository,  string searchCriteria, string countryId = null)
        {
            return repository
                .Queryable()
                .Where(x =&gt; (countryId != null ? x.CountryId == countryId : true) &amp;&amp; x.Name.Contains(searchCriteria))
                .AsEnumerable();
        }
</code></pre>

<p>Ideally , I would like to exclude the criteria in the filter when CountryId is NULL.</p>

<p>-Alan-</p>