Skip to content

PgCastAttribute

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Exposes a static method or C# conversion declaration as a PostgreSQL function and a cast from its first parameter to its return type. Add PgFunction to customize the backing function’s name, schema, or execution options.

[AttributeUsage(AttributeTargets.Method)]
public sealed class PgCastAttribute : Attribute

Declares a cast with the selected conversion context. C# implicit or explicit syntax does not select the PostgreSQL conversion context. Conversions retain their exact parameter and result types, including checked implementations.

Inheritance: object, Attribute

Exposes a static method or C# conversion declaration as a PostgreSQL function and a cast from its first parameter to its return type. Add PgFunction to customize the backing function’s name, schema, or execution options.

public PgCastAttribute(PgCastContext context = PgCastContext.Explicit)

Parameters:

context — PgCastContext

The permitted conversion context; explicit by default.

Declares a cast with the selected conversion context. C# implicit or explicit syntax does not select the PostgreSQL conversion context. Conversions retain their exact parameter and result types, including checked implementations.

Gets where PostgreSQL may apply this cast.

public PgCastContext Context { get; }

Value: PgCastContext

Gets or sets the dependency identifier for the cast, independently of its backing function.

public string? Id { get; set; }

Value: string

Gets or sets declarations that must precede CREATE CAST.

public string[] Requires { get; set; }

Value: string[]