Querying .NET DataSet and ignore rows that contain NULL I've written some code to read a column of data from a dataset called AltIds.  The values are nullable.  My code is written to find all the values in the column that are not null and write them to an array.

Guid[] altIds = myDataSet.Tables[0].AsEnumerable()
  .Select(row =&gt; row.Field&lt;Guid?&gt;("AltId"))
  .Where(x =&gt; x.HasValue)
  .Select(x=&gt;x.Value)
  .ToArray();


The code works, but it seems a bit complicated.  Is there a better way to do this?
What you have is fine. You could restructure it to eliminate one of the selects, but then you would repeat yourself with the row. 

var altIds = myDataSet.Tables[0].AsEnumerable()
                 .Where(row =&gt; row.Field&lt;Guid?&gt;("AltId").HasValue)
                 .Select(row =&gt; row.Field&lt;Guid?&gt;("AltId").Value)
                 .ToArray();


You could rewrite it in query expression syntax, but that's only less complicated if you find fluent syntax more so. 

var altIds = (from row in myDataSet.Tables[0].AsEnumerable()
             let x = row.Field&lt;Guid?&gt;("AltId")
             where x.HasValue
             select x.Value).ToArray();


Either way, it's six in one hand, half a dozen in the other. I find your code readable, and it passes the "does what it is supposed to" test, so I wouldn't worry about this snippet.