I have MS Access database with related tables. In the studio, using standard tools added a new DataSource and Dataset (one class (read one DataTable) - one table).
Suppose, for example, I have 2 tables: Table1 and Table2. 1 of the Table1 columns is the ID in Table2. Now in DataSet.Table1.Row there are properties ID, other columns , Table2Row. In turn, Table2Row is a class corresponding to 1 row of Table2.
Now I want to bring the Table1 table to the DataGrid, but so that instead of the Table2ID column I display some columns from the corresponding Table2 row.
Now I have copied the DataTable of the first table, added the necessary columns there and in the foreach loop I wrote down the necessary values from the corresponding row of the Table2 table:
var fullTable = _dataSet.Ord; fullTable.Columns.Add("CopyName"); fullTable.Columns.Add("ExecutorName"); fullTable.Columns.Add("OrdererName"); foreach (var row in fullTable.AsEnumerable()) { if (row.CopyRow != null) row["CopyName"] = row.CopyRow.Title; if (row.ExecutorRow != null) row["ExecutorName"] = row.ExecutorRow.Name; if (row.OrdererRow != null) row["OrdererName"] = row.OrdererRow.Name; } The question is: is it possible to do without unnecessary copying? Or how to do it easier and less expensive.