MetadataDefaults Class
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:
string columns, the default value is string.Empty (even when nullable).
string), the default value is null.
DataTypeNames.BINARY), the default value is an empty byte array.
0, false, default(DateTime), Guid.Empty).
JSON, SPATIAL, and OBJECT, the default value is null.
Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
public static class MetadataDefaults
{
public static object? GetDefaultValue(string? dataType, bool isNullable);
}
// 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);
dataType is null or empty, GetDefaultValue returns null.
null.
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.