Datatable.AsEnumerable()

Datatable.AsEnumerable() giving me the error NullReferenceException: Object reference not set to an instance of an object

using UnityEngine;
using System.Data;
using System.Linq;
using System;

public class CAS_Test : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        DataTable testTable = new DataTable("testTable");
        Console.WriteLine(testTable.AsEnumerable());
    }
}

Error

NullReferenceException: Object
reference not set to an instance of an
object
System.Data.DataTableExtensions.AsEnumerable
(System.Data.DataTable source) (at
:0)
CAS_Test.Start () (at
Assets/CAS_Test.cs:12)

I have also tested with data in the data table. This happens only in Unity . I tested in with a c# compiler and the two lines works.

I need this to use Linq query.

Using “.Net 4.x” seems to resolve the issue.

The setting is under ProjectSetting → Player → OtherSettings → Api Compatibility level