I realize this has been answered a few times over, but just to offer another approach:
I like to use the .Cast<T>()
method, it helps me maintain sanity in seeing the explicit type defined and deep down I think .AsEnumerable()
calls it anyways:
var results = from myRow in myDataTable.Rows.Cast<DataRow>()
where myRow.Field<int>("RowNo") == 1 select myRow;
or
var results = myDataTable.Rows.Cast<DataRow>()
.FirstOrDefault(x => x.Field<int>("RowNo") == 1);
As noted in comments, no other assemblies needed as it's part of Linq (Reference)