TryGetValue Method
The TryGetValue method attempts to retrieve a field value from an observable data row by column name.
It first tries an exact (case-sensitive) lookup, and if that fails it performs a case-insensitive lookup by
searching for an existing key whose casing differs.
This makes the method tolerant to differences in column name casing (for example, "Name" vs
"name"), while still keeping the fast path for exact matches.
If observableDataRow is null, the method returns false and sets
value to null.
/// <summary>
/// Tries to get value from the field by using both, case sensitive and then case-insensitive column name
/// </summary>
/// <param name="observableDataRow">Observable Data row</param>
/// <param name="columnName">Column name</param>
/// <param name="value">Requested value</param>
/// <returns>True if requested requested field with column name exists in data row, otherwise false</returns>
public static bool TryGetValue(this IObservableDataRow? observableDataRow, string columnName, out object? value)
Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll
Retrieve a value using either exact or case-insensitive column name matching:
// 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 TryGetValue by passing column name in different casing
// Value "ET01" found
object? value;
bool found = employmentTypeObservableDataRow.TryGetValue("coDE", out value);
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.