Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


.NET5 Cannot Serialize DataTable
Issue: Cannot pass type DataTable in controller to angular (serialization of System.DataType not allowed)

Solution: Convert table to an object and pass that instead:

IEnumerable<Dictionary<string, object>> result = source.Select().Select(
x => x.ItemArray.Select((a, i) => new { Name = source.Columns[i].ColumnName,
Value = (a == DBNull.Value ? null : a) })
.ToDictionary(a => a.Name, a => a.Value));

Created By: amos 9/22/2021 3:19:55 PM