DataTable does not contain definition for AsEnumerable

Add System.Data.DataSetExtensions from "nuget" or "add reference"

Add this code:

using System.Data.DataSetExtensions;

In all cases where this happens, the reference to System.Data.DataSetExtensions.dll was missing. If in doubt, try creating a simple console project targeting .NET 4 with a reference to System.Data.DataSetExtensions.dll, to verify that adding the reference actually works.

Also note that you only need to use the System.Data namespace.

BTW mapDataTable is a DataTable, right?


The method you want is in the System.Data namespace, so that using directive is fine, but you also need a reference to the System.Data.DataSetExtensions assembly. Are you sure you've got that reference as an assembly reference?

It's not clear why you've got a using directive for a System.Data.DataSetExtensions namespace - does that not raise an error?

What is the exact error with the AsEnumerable() call? (I'm surprised about the error you're getting with the second form... that's not the error I'd have expected.)