Linq-to-Sql Contains an int? inside a list of int Curious if there is a better way to write a repository method that receives argument List&lt;int&gt; and checks if the database Contains an int?.

public List&lt;int&gt; GetNumbersByNumbers(IEnumerable&lt;int&gt; numbers)
{
    var convertedNumbers = numbers.Select(m =&gt; (int?)m);
    return Context.TblNumbers
        .Where(m =&gt; convertedNumbers.Contains(m.Number))
        .Select(m =&gt; m.Number.GetValueOrDefault())
        .ToList();
}
Another way to do this is to remove NULL values from the comparison to begin with, like so:

return Context.TblNumbers
              .Where(m =&gt; m.Number != null)
              .Where(m =&gt; convertedNumbers.Contains(m.Number.Value))
              .Select(m =&gt; m.Number.Value)
              .ToList();


I think this also reads more naturally since you only have the chance to match on non-null values anyway, instead of GetValueOrDefault() which implies you might need to get a default value.