Search code examples
c#asp.net-corebotframework

How to fix 'DataTable' does not contain a definition for 'AsEnumerable' Error in Microsoft Botframework v4?


Hi i'm doing a chatBot project with Microsoft Botframework V4 in c# with VS. Actually the project is a migration from Botframework v3 to V4. In v4, how to use DataTable extensions. Like CopytoDataTable works only in v3 and not in v4.

The Usings for datatable extensions like 'using system.data.datasetextensions'

DataTable ResultTable = new DataTable(); DataTable TempTable = query.CopyToDataTable<DataRow>(); ResultTable.Merge(TempTable); ResultTable = ResultTable.DefaultView.ToTable()

Error is 'DataTable' does not contain a definition for 'AsEnumerable' and the best extension method overload 'ConfigurationExtensions.AsEnumerable(IConfiguration)' requires a receiver of type 'IConfiguration'


Solution

  • DataTable.AsEnumerable() is an extension-method defined in System.Data.DataSetExtensions.

    If you're targeting .NET Framework 4.x then in your project add a reference to that framework assembly (System.Data.DataSetExtensions.dll).

    If you're targeting .NET Core, add a NuGet package reference to System.Data.DataSetExtensions ( https://www.nuget.org/packages/System.Data.DataSetExtensions )