PgEnums
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Converts generated enum labels without reflection and resolves their live PostgreSQL type identities.
public static class PgEnumsInheritance: object
Methods
Section titled “Methods”GetLabel<T>(T)
Section titled “GetLabel<T>(T)”Gets the exact PostgreSQL label without requiring a backend. Undefined numeric values are rejected.
public static string GetLabel<T>(T value) where T : struct, EnumType parameters:
T
A C# enum declared with PgEnum.
Parameters:
value — T
The declared enum value.
Returns: string
The case-sensitive label.
GetTypeOid<T>()
Section titled “GetTypeOid<T>()”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, EnumType parameters:
T
A C# enum declared with PgEnum.
Returns: uint
The current PostgreSQL type OID.
GetValueOid(uint, string)
Section titled “GetValueOid(uint, string)”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.
GetValueOid<T>(T)
Section titled “GetValueOid<T>(T)”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, EnumType parameters:
T
A C# enum declared with PgEnum.
Parameters:
value — T
The declared enum value.
Returns: uint
The pg_enum row OID.
Lookup(uint)
Section titled “Lookup(uint)”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.
Parse<T>(string)
Section titled “Parse<T>(string)”Converts an exact PostgreSQL label without requiring a backend. Unknown labels are rejected.
public static T Parse<T>(string label) where T : struct, EnumType parameters:
T
A C# enum declared with PgEnum.
Parameters:
label — string
The exact case-sensitive label.
Returns: T
The declared enum value.