DataRowFactory Class
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: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
public static class DataRowFactory
{
public static IDataRow CreateEmpty(int initialCapacity = 0);
public static IDataRow CreateFromColumnsWithDefaults(IReadOnlyList<IColumnMetadata> listOfColumnMetadata);
}
IDataRow (no predefined column values). If initialCapacity is greater than zero,
the underlying value storage is pre-sized to reduce dictionary resizing during assignments.
IDataRow and initializes each column listed in listOfColumnMetadata with a default value.
Default values are computed using MetadataDefaults.GetDefaultValue based on each column s data type and nullability.
This method is typically used to create rows consistent with a table schema.
// 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"];
CreateEmpty when you need a row that will be populated later.
CreateFromColumnsWithDefaults to initialize a row in a schema-driven UI (for example, dynamic forms).
initialCapacity can reduce allocations.
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.