Appearance
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
| Name | Description |
|---|---|
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
| Name | Description |
|---|---|
ClrType | Gets or sets the CLR type associated with RawValue. |
IsBoolean | Gets a value indicating whether the underlying value is a Boolean. |
IsDecimal | Gets a value indicating whether the underlying value is a Decimal. |
IsFloatingPoint | Gets a value indicating whether the underlying value is a floating-point type |
IsWholeNumber | Gets a value indicating whether the underlying value is a whole-number type |
Precision | Gets or sets the SQL precision associated with this value, if known. |
RawValue | Gets or sets the raw CLR value wrapped by this instance. |
Scale | Gets or sets the SQL scale associated with this value, if known. |
SqlType | Gets or sets the SQL type name (e.g. numeric(18, 2)) associated with this value, if any. |
Methods
| Name | Description |
|---|---|
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.