Skip to content

SqlNumeric Class ​

Definition ​

Wraps a numeric CLR value together with optional SQL metadata (precision, scale, and SQL type) so it can represent the full range of database numeric types in a uniform way.

  • Namespace: JASE.Database
  • Assembly: JASE.Database.dll

Constructors ​

NameDescription
SqlNumeric()Creates an empty SqlNumeric with no value assigned.
SqlNumeric(IColumnInfoNumeric column, object value)Creates a new SqlNumeric using the numeric metadata from a database column and the supplied CLR value.
SqlNumeric(Type type, bool isMin)Creates a SqlNumeric representing either the minimum or maximum value of the specified numeric CLR type.
SqlNumeric(object value)Creates a new SqlNumeric wrapping the specified CLR value.

Properties ​

NameDescription
ClrTypeGets or sets the CLR type associated with RawValue.
IsBooleanGets a value indicating whether the underlying value is a Boolean.
IsDecimalGets a value indicating whether the underlying value is a Decimal.
IsFloatingPointGets a value indicating whether the underlying value is a floating-point type
IsWholeNumberGets a value indicating whether the underlying value is a whole-number type
PrecisionGets or sets the SQL precision associated with this value, if known.
RawValueGets or sets the raw CLR value wrapped by this instance.
ScaleGets or sets the SQL scale associated with this value, if known.
SqlTypeGets or sets the SQL type name (e.g. numeric(18, 2)) associated with this value, if any.

Methods ​

NameDescription
T As()Converts the underlying value to T using System.Convert.ChangeType(System.Object,System.Type).
BigInteger? AsBigInteger()Attempts to convert the underlying value to a BigInteger.
decimal? AsDecimal()Attempts to convert the underlying value to a Decimal.
bool Equals(SqlNumeric other)Determines whether the current instance is equal to another SqlNumeric based on the underlying RawValue.
bool Equals(object obj)Determines whether the current instance is equal to another SqlNumeric based on the underlying RawValue.
int GetHashCode()Returns a hash code for this instance.
string ToString()Returns the string representation of the underlying value.

Remarks ​

The underlying value is stored as Object in RawValue. Only a limited set of numeric-related CLR types are supported (integral types, floating-point, Decimal, Boolean, and their nullable counterparts, plus Enum).

Use As / AsDecimal / AsBigInteger to project the wrapped value into a concrete numeric type.