Convert IEnumerable to a DataTable

Convert IEnumerable to a DataTable

1. How to convert an IEnumerable to a DataTable in the same way as we use ToList or ToArray

* DataSet does not support System.Nullable<>.

 

2. LINQ to DataTable

 

3. 有時候 List<T> 沒有資料會發生 Exception 改寫如下