CopyFrom Method
The CopyFrom method copies column values from a source IDataRow into a target
IObservableDataRow using a provided list of column metadata. The method iterates over
sourceColumns and, for each column name, attempts to read the value from the source row and assign it
to the observable row.
This method uses the observable row indexer (observableDataRow[columnName] = value) so that
observable row events fire as expected.
/// <summary>
/// Copies filed values from the data row into observable data row using the provided column metadata list.
/// Missing columns are ignored; extra target columns are left untouched.
/// </summary>
/// <param name="observableDataRow">Observable data row</param>
/// <param name="dataRow">Source data row</param>
/// <param name="listOfColumnMetadata">List of column metadata</param>
public static void CopyFrom(this IObservableDataRow? observableDataRow, IDataRow dataRow, IList<IColumnMetadata> listOfColumnMetadata)
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
// 1. Create a new observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create observable table and row
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);
IObservableDataRow observableDepartmentDataRow = departmentObservableDataTable.AddNewRow();
// 3. Create refreshed DataSet / DataTable / DataRow
IDataSet refreshedDataSet = DataSetFactory.CreateDataSet();
IDataTable refreshedDepartmentDataTable = refreshedDataSet.AddNewTable("Department");
refreshedDepartmentDataTable.AddColumn("Id", DataTypeNames.INT32);
refreshedDepartmentDataTable.AddColumn("Name", DataTypeNames.STRING);
IDataRow refreshedDepartmentDataRow = refreshedDataSet.Tables["Department"].AddNewRow();
refreshedDepartmentDataRow["Id"] = 1;
refreshedDepartmentDataRow["Name"] = "Sales";
refreshedDepartmentDataRow.AcceptChanges();
// 5. Copy values from the refreshedDepartmentDataRow row into observableDepartmentDataRow
observableDepartmentDataRow.CopyFrom(refreshedDepartmentDataRow, departmentObservableDataTable.Columns);
Table of Content POCO DataSet Observable Data Row Members
Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the
Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate
credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness
or suitability of the information and are not responsible for any damages
resulting from its use.