private static IColumn CreateAndFillColumn(DataColumn dataColumn) { var colId = dataColumn.Table.Columns.IndexOf(dataColumn); var colData = (from DataRow row in dataColumn.Table.Rows select row[colId]).ToList(); return(TableFactory.CreateColumn(dataColumn, colData.OrderBy(o => o).Distinct())); }
private static ITable ExtractSchema(DataTable dataTable) { //Get keys var keys = dataTable.PrimaryKey.Select(k => dataTable.Columns.IndexOf(k.ColumnName)).ToList(); var table = TableFactory.CreateTable(dataTable.Columns.Count, keys); table.Columns.Select( (c, i) => new { i, col = CreateAndFillColumn(dataTable.Columns[i]) } ).ToList() .ForEach(c => table.Columns[c.i] = c.col); return(table); }