TryGetFieldKeyByColumnName Method
The TryGetFieldKeyByColumnName method attempts to locate the actual field key stored in a data row
for a specified column name. It first checks for an exact (case-sensitive) key match, and if not found it scans
existing keys using a case-insensitive comparison.
This method is commonly used by other helpers (such as TryGetValue) to support case-insensitive
access when the row’s stored key casing differs from the caller’s requested column name.
If observableDataRow is null, the method returns false and sets
foundFieldKey to the provided columnName.
/// <summary>
/// Tries to get field key by column name
/// </summary>
/// <param name="observableDataRow">Observable data row</param>
/// <param name="columnName">Column name</param>
/// <param name="foundFieldKey">Found field key</param>
/// <returns>True if field key found, otherwise false</returns>
public static bool TryGetFieldKeyByColumnName(this IObservableDataRow? observableDataRow, string columnName, out string foundFieldKey)
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
Find the actual key in the row, even if the caller uses different casing:
// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();
// 2. Create EmploymentType table and add a new row
IObservableDataTable employmentTypeObservableDataTable = observableDataSet.AddNewTable("EmploymentType");
employmentTypeObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
employmentTypeObservableDataTable.AddColumn("Code", DataTypeNames.STRING);
employmentTypeObservableDataTable.AddColumn("Description", DataTypeNames.STRING);
IObservableDataRow employmentTypeObservableDataRow = employmentTypeObservableDataTable.AddNewRow();
employmentTypeObservableDataRow["Id"] = 1;
employmentTypeObservableDataRow["Code"] = "ET01";
employmentTypeObservableDataRow["Description"] = "Full Time";
// 3. Call TryGetFieldKeyByColumnName by passing column name in different casing
// Field key "Description" found
bool found = TryGetFieldKeyByColumnName("DESCRIPTION", out string? fieldKey);
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.