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
dtDataTableThe DataTable containing the column to convert.
columnNamestringThe name of the column to convert.
oldTypeTypeThe current type of the column.
newTypeTypeThe 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.