DataRowFactory Class

Overview

The DataRowFactory class is a static helper that creates IDataRow instances for common scenarios. It centralizes row creation logic, including optional initialization of internal storage capacity and applying default values based on column metadata.

Namespace and Assembly

Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll

Declaration

public static class DataRowFactory
{
    public static IDataRow CreateEmpty(int initialCapacity = 0);
    public static IDataRow CreateFromColumnsWithDefaults(IReadOnlyList<IColumnMetadata> listOfColumnMetadata);
}

Public Methods

Usage Example

// 1. Create a table schema (column metadata)
IDataSet dataSet = DataSetFactory.CreateDataSet();
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);

// 2. Create a new row with default values based on column metadata
IDataRow departmentDataRow = DataRowFactory.CreateFromColumnsWithDefaults(departmentDataTable.Columns);

// 3. Read a default-initialized value (example)
object? nameValue = departmentDataRow["Name"];

Usage Notes

 

Table of Content POCO DataSet PocoDataSet.Data

 


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.