Table of Contents

Method ConvertColumnType

Namespace
YndigoBlue.Velocity.Utils
Assembly
YndigoBlue.Velocity.dll

ConvertColumnType(DataTable, string, Type, Type)

Converts a DataTable column from one type to another, preserving data where possible.

public static void ConvertColumnType(this DataTable dt, string columnName, Type oldType, Type newType)

Parameters

dt DataTable

The DataTable containing the column to convert.

columnName string

The name of the column to convert.

oldType Type

The current type of the column.

newType Type

The target type for the column.

Remarks

This method handles special conversions for Geometry, Geography, and DateOnly types. For other types, it uses Convert.ChangeType. Null and DBNull values are preserved.