the type arguments for method system linq enumerable as enumerable Error

DataTable tblFiltered = dtable.AsEnumerable()
          .Where(row => row.Field<String>("empsalary") > 12000)
          .OrderByDescending(row => row.Field<String>("empsalary"))
          .CopyToDataTable();

The above code throws The Type arguments for the method Syste.Linq.Enumerable.AsEnumerable cannot be inferred from the usage.

Jon Skeet
people
quotationmark

You haven't told us the type of dtable, but assuming it's DataTable, I suspect you intended to use DataTableExtensions.AsEnumerable rather than Enumerable.AsEnumerable... in which case you're probably just missing either a using directive to import the extension method:

using System.Data;

... or (more likely) a reference to the System.Data.DataSetExtensions assembly which contains the DataTableExtensions type.

people

See more on this question at Stackoverflow