Skip to content

PgEnums

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Converts generated enum labels without reflection and resolves their live PostgreSQL type identities.

public static class PgEnums

Inheritance: object

Gets the exact PostgreSQL label without requiring a backend. Undefined numeric values are rejected.

public static string GetLabel<T>(T value) where T : struct, Enum

Type parameters:

T

A C# enum declared with PgEnum.

Parameters:

value — T

The declared enum value.

Returns: string

The case-sensitive label.

Resolves the enum type in the active extension’s installation schema or its declared fixed schema. The result is looked up on each call so relocation and type recreation cannot leave stale OIDs.

public static uint GetTypeOid<T>() where T : struct, Enum

Type parameters:

T

A C# enum declared with PgEnum.

Returns: uint

The current PostgreSQL type OID.

Resolves a label of any enum type, including one without a generated managed mapping, to its pg_enum value OID. Use GetOid(string) to find the type by name. PostgreSQL validates the label and transaction visibility on the active backend.

public static uint GetValueOid(uint typeOid, string label)

Parameters:

typeOid — uint

The enum type OID.

label — string

The exact case-sensitive label.

Returns: uint

The pg_enum row OID.

Resolves the stored PostgreSQL enum value OID from a generated value and its current catalog type. PostgreSQL validates the label and transaction visibility on the active backend.

public static uint GetValueOid<T>(T value) where T : struct, Enum

Type parameters:

T

A C# enum declared with PgEnum.

Parameters:

value — T

The declared enum value.

Returns: uint

The pg_enum row OID.

Looks up an enum datum OID on the active backend and copies its label, type and sort order. This also supports enum types without a generated managed mapping.

public static PgEnumInfo Lookup(uint valueOid)

Parameters:

valueOid — uint

The pg_enum row OID, as returned by GetValueOid.

Returns: PgEnumInfo

Owned catalog information.

Converts an exact PostgreSQL label without requiring a backend. Unknown labels are rejected.

public static T Parse<T>(string label) where T : struct, Enum

Type parameters:

T

A C# enum declared with PgEnum.

Parameters:

label — string

The exact case-sensitive label.

Returns: T

The declared enum value.