private SourceMap CreateMap(DataTable dataTable, DataColumn column) { var values = dataTable.Rows.Cast <DataRow>() .Select(p => p[column.Ordinal]).ToList(); var dataType = _dataTypeDetector.Detect(values); var semanticType = _semanticTypeDetector.Detect(dataType, values); var map = _factory.Create( column.Ordinal, column.ColumnName, dataType, semanticType); return(map); }
// TODO: Should this method just return direct (i.e. non-infered) data types? // TODO: Or should I eliminate it all together? private List <DataColumn> GetDataColumns(DataTable dataTable) { var dataColumns = new List <DataColumn>(); for (int i = 0; i < dataTable.Columns.Count; i++) { var values = dataTable.Rows.Cast <DataRow>() .Select(p => p[i]).ToList(); var dataType = _dataTypeDetector.Detect(values); var columnName = dataTable.Columns[i].ColumnName; var dataColumn = new DataColumn { ColumnName = columnName, DataType = dataType, }; dataColumns.Add(dataColumn); } return(dataColumns); }