1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| var dictList = new List<Dictionary<string, object>> { new Dictionary<string, object> { {"Id", 1}, {"Name", "Jack"}, {"Birth", DateTime.Parse("2022-05-01")}, {"Price", null}, }, new Dictionary<string, object> { {"Id", 2}, {"Name", "Flash"}, {"Birth", DateTime.Parse("2022-05-01")}, {"Price", 123m}, {"Home", null}, } };
var datatable = dictList.DeepToDataTable();
Assert.Equal(typeof(decimal), dt.Columns["Price"]!.DataType); Assert.Equal(typeof(string), dt.Columns["Home"]!.DataType);
|