Skip to content

PgNumericPrecisionAttribute

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Applies PostgreSQL numeric precision and scale to a generated function parameter or return value. Values are rounded with PostgreSQL’s typmod rules, then checked for overflow.

[AttributeUsage(AttributeTargets.Parameter|AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
public sealed class PgNumericPrecisionAttribute : Attribute

Use on PgNumeric or decimal, including nullable forms. Constraints apply at the SQL boundary; direct C# calls bypass them. Negative scales and scales above precision require PostgreSQL 15 or later. PostgreSQL function signatures themselves do not retain numeric type modifiers, so the generated dispatcher enforces this contract.

Inheritance: object, Attribute

Declares numeric precision and scale.

public PgNumericPrecisionAttribute(int precision, int scale = 0)

Parameters:

precision — int

The maximum significant digits, one through 1000.

scale — int

The scale, -1000 through 1000. The default is zero.

Gets or sets the exact C# tuple element to constrain within a typed aggregate argument group. Omit for a scalar parameter or return value.

public string? Element { get; set; }

Value: string

Gets the maximum significant digits.

public int Precision { get; }

Value: int

Gets the declared scale.

public int Scale { get; }

Value: int