EnumerateValues Method

Overview

The EnumerateValues method returns an enumerable sequence of all field values in a data row as KeyValuePair<string, object?> items, where the key is the field (column) name and the value is the current field value.

This method is a convenience wrapper over IDataRow.Values and can be used to iterate over row fields in a foreach loop.

Declaration

/// <summary>
/// Enumerates values
/// </summary>
/// <param name="dataRow" >Data row</param>
/// <returns>Enumerated values</returns>
public static IEnumerable<KeyValuePair<string, object?>> EnumerateValues(this IDataRow dataRow)

Namespace and Assembly

Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll

Usage Example

// 1. Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();

// 2. Create a table, add columns and a row
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);

IDataRow departmentDataRow = departmentDataTable.AddNewRow();
departmentDataRow.UpdateFieldValue("Id", 1);
departmentDataRow.UpdateFieldValue("Name", "HR");

// 3. Enumerate all values in the row
foreach (KeyValuePair<string, object?> pair in departmentDataRow.EnumerateValues())
{
  string fieldName = pair.Key;
  object? fieldValue = pair.Value;
}

 

Table of Content POCO DataSet DataRow 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.