How to insert type declaration in lambda syntax?
Collects:
from DataRow row in dataTable.Rows select transformOneRow(row)
Not compiling:
dataTable.Rows.Select( r => transformOneRow(r))
with an error
'System.Data.DataRowCollection' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Data.DataRowCollection' could be found
I see that the syntax of the request allows a type; what makes the compiler happy.
How to insert type declaration in lambda syntax?
I have the following ways:
dataTable.AsEnumerable().Select(r => transformOneRow(r));
dataTable.Rows.Cast<DataRow>().Select(r => transformOneRow(r));
dataTable.Rows.OfType<DataRow>().Select(r => transformOneRow(r));
source
share