ContainsColumn Method

Overview

The ContainsColumn method determines whether a observable data table contains a column with the specified name. The comparison is performed in a case-insensitive manner.

This helper is typically used to validate schema assumptions before reading or writing values, especially when working with dynamically generated tables.

Declaration

/// <summary>
/// Returns true if table contains column with specified name
/// </summary>
/// <param name="observableDataTable">Observable data table</param>
/// <param name="columnName">Column name</param>
/// <returns>True if exists, otherwise false</returns>
public static bool ContainsColumn(this IObservableDataTable? dataTable, string? columnName)

Namespace and Assembly

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

Behavior

Usage Example

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

// 2. Create Department observable table with rows in different states
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);

bool containsIdColumn = departmentObservableDataTable.ContainsColumn("ID"); // true
bool containsNameColumn = departmentObservableDataTable.ContainsColumn("name"); // true
bool containsCodeColumn = departmentObservableDataTable.ContainsColumn("Code"); // false

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.