AddColumns Method

Overview

The AddColumns method assigns a complete list of column metadata observable data table. In addition, it ensures that every existing row in the table receives each of the columns from the provided list.

This method is typically used when you already have column metadata available (for example, schema loaded from a database or generated from a POCO interface) and want to apply the full schema to a table in one call.

Declaration

/// <summary>
/// Adds columns to observable data table (delegates to inner table)
/// </summary>
/// <param name="observableDataTable">Observable data table</param>
/// <param name="listOfColumnMetadata">List of column metadata</param>
public static void AddColumns(this IObservableDataTable? observableDataTable, List<IColumnMetadata> listOfColumnMetadata)

Namespace and Assembly

Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll

Behavior

Usage Example

// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();

// 2. Create list of column metadata
List<IColumnMetadata> listOfColumnMetadata = new List<IColumnMetadata>();

IColumnMetadata columnMetadata = new ColumnMetadata();
columnMetadata.ColumnName = "Id";
columnMetadata.DataType = DataTypeNames.INT32;
columnMetadata.IsNullable = false;
columnMetadata.IsPrimaryKey = true;
listOfColumnMetadata.Add(columnMetadata);

columnMetadata = new ColumnMetadata();
columnMetadata.ColumnName = "FirstName";
columnMetadata.DataType = DataTypeNames.STRING;
listOfColumnMetadata.Add(columnMetadata);

columnMetadata = new ColumnMetadata();
columnMetadata.ColumnName = "LastName";
columnMetadata.DataType = DataTypeNames.STRING;
listOfColumnMetadata.Add(columnMetadata);

// 3. Create Employee observable data table
IObservableDataTable employeeObservableDataTable = observableDataSet.AddNewTable("Employee");

// 4. Add columns to the Employee table
employeeObservableDataTable.AddColumns(listOfColumnMetadata);

Notes

 

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.