Skip to main content

CastConverter

  • Namespace: PPDS.Dataverse.Query.Execution.Functions
  • Assembly: PPDS.Dataverse
  • Kind: Class

Summary

Implements T-SQL CAST/CONVERT type conversion semantics. Supports common Dataverse types: int, bigint, decimal, float, nvarchar, varchar, datetime, date, bit, uniqueidentifier, money.

Members

Methods

Convert

object Convert(object value, string targetType, Nullable<int> style)

Converts a value to the specified SQL type.

  • Param value: The value to convert. Null propagates as null.

  • Param targetType: The target SQL type name (case-insensitive), e.g. "int", "nvarchar(100)".

  • Param style: Optional CONVERT style code for datetime/string formatting.

  • Returns: The converted value, or null if the input is null.

TryConvert

object TryConvert(object value, string targetType, Nullable<int> style)

TRY_CAST / TRY_CONVERT: converts a value to the specified SQL type. Returns NULL on failure instead of throwing.

  • Param value: The value to convert. Null propagates as null.

  • Param targetType: The target SQL type name (case-insensitive).

  • Param style: Optional CONVERT style code.

  • Returns: The converted value, or null if conversion fails.