Table of Contents

Class DecimalPrecisionAttribute

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Declares the decimal precision and scale of a mapped decimal property. The pair is read by IPropertyMetadata (DecimalPrecision and DecimalScale) and used where a provider needs the declared precision/scale, such as the column metadata of a table-valued parameter.

The declared domain is provider-neutral and bounded by SQL Server's maximum: precision must be between 1 and 38, and scale between 0 and the precision. A provider without a native decimal precision (for example ClickHouse's Decimal(P, S)) honours the same pair; a provider that does not need it keeps its default. The pair is validated against the type actually bound for the column: a non-decimal model mapped through a value converter to decimal is accepted, while a decimal model mapped to a non-decimal representation (a converter to string or a JSON column) is rejected. An out-of-range pair throws ArgumentOutOfRangeException; a pair declared on a non-decimal bound type or a partially declared pair throws InvalidOperationException.

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class DecimalPrecisionAttribute : Attribute
Inheritance
DecimalPrecisionAttribute
Inherited Members
Extension Methods

Remarks

The equivalent fluent mapping is DecimalPrecision(int, int). The attribute affects only the declared column metadata; nextorm does not generate DDL, so the column must already have a matching precision/scale (the equivalent of HasColumnType("decimal(12,4)") in EF Core).

Constructors

DecimalPrecisionAttribute(int, int)

Creates an attribute declaring precision and scale.

public DecimalPrecisionAttribute(int precision, int scale)

Parameters

precision int

The total number of decimal digits (1 to 38).

scale int

The number of digits to the right of the decimal point (0 to precision).

Properties

Precision

The total number of decimal digits (1 to 38).

public int Precision { get; set; }

Property Value

int

Scale

The number of digits to the right of the decimal point (0 to Precision).

public int Scale { get; set; }

Property Value

int