MetadataDefaults Class

Overview

The MetadataDefaults class provides default values based on POCO DataSet column metadata. It is typically used when creating new rows in schema-driven scenarios to initialize each cell with an appropriate default value based on a column’s data type token (for example, values from DataTypeNames) and nullability.

The default selection rules implemented by MetadataDefaults are:

Namespace and Assembly

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

Declaration

public static class MetadataDefaults
{
    public static object? GetDefaultValue(string? dataType, bool isNullable);
}

Public Methods

Usage Example

// 1. Compute defaults using type tokens and nullability
object? nameDefault = MetadataDefaults.GetDefaultValue(DataTypeNames.STRING, isNullable: true);
object? idDefault = MetadataDefaults.GetDefaultValue(DataTypeNames.INT32, isNullable: false);
object? optionalGuidDefault = MetadataDefaults.GetDefaultValue(DataTypeNames.GUID, isNullable: true);

// 2. Typical usage: create a row with defaults using DataRowFactory
IDataSet dataSet = DataSetFactory.CreateDataSet();
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);

IDataRow departmentDataRow = DataRowFactory.CreateFromColumnsWithDefaults(departmentDataTable.Columns);

Remarks

 

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.