AddColumnsFromInterface Method
The AddColumnsFromInterface method adds columns to an observable data table by reflecting over a POCO interface type.
It collects the specified interface and its entire inheritance chain, then adds a column for each public instance property.
For each interface property, the method determines:
Columns are added using ObservableDataTableExtensions.AddColumn, so existing rows in the table are extended with the new columns.
/// <summary>
/// Adds columns from interface type to observable table (delegates to inner table)
/// </summary>
/// <typeparam name="TInterface">Interface type</typeparam>
/// <param name="observableDataTable">Observable data table</param>
public static void AddColumnsFromInterface<TInterface>(this IObservableDataTable? observableDataTable)
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
observableDataTable is null, returns immediately.interfaceType.IsInterface is true. Otherwise throws ArgumentException.
interfaceType and all inherited interfaces recursively.
dataTable.AddColumn(columnName, dataTypeName, isNullable).
Primary-key and foreign-key conventions (if any) are applied by AddColumn.
Assume there is an interface that defines the schema of an EmploymentType entity:
/// <summary>
/// Defines employment type functionality
/// </summary>
internal interface IEmploymentType
{
int Id { get; set; }
string Code { get; set; }
string? Description { get; set; }
}
You can create a table and add columns from the interface:
// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Add EmploymentType observable data table
IObservableDataTable employmentTypeObservableDataTable = observableDataSet.AddNewTable("EmploymentType");
// 3. Add columns from the POCO interface
employmentTypeObservableDataTable.AddColumnsFromInterface<IEmploymentType>();
AddColumn. If the table already contains a column with the same name,
AddColumn will throw a KeyDuplicationException.
AddColumn extends existing rows, calling AddColumnsFromInterface on a table with many rows
may have a performance impact.
Table of Content POCO DataSet Observable Data Table 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.