Table of Contents

Class SqlFunctionAttribute

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Maps a CLR method to a database scalar function. Apply it to a placeholder method that is only ever referenced inside a query expression (its body is never executed, so => default! or throw null! is enough) or to the declaring type to map every method by name.

The call is translated to [schema.]name(arg1, arg2, ...). For an instance method the target (node.Object) is emitted as the first argument. The mapped function must already exist in the target database: nextorm only emits a call to it, it does not create it.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class SqlFunctionAttribute : Attribute
Inheritance
SqlFunctionAttribute
Inherited Members
Extension Methods

Constructors

SqlFunctionAttribute()

Initializes a new instance of the SqlFunctionAttribute class. The SQL function name defaults to the CLR method name.

public SqlFunctionAttribute()

SqlFunctionAttribute(string)

Initializes a new instance of the SqlFunctionAttribute class with an explicit SQL function name.

public SqlFunctionAttribute(string name)

Parameters

name string

The SQL function name to call; must not be null.

Properties

IsAggregate

Whether the mapped function is an aggregate (it folds the rows of a group into one value). SelectGroup uses this to keep an aggregate call opaque when it infers the grouping keys: the aggregate's arguments never become keys, and a group-less projection that contains one is rendered as a global aggregate. Defaults to false (a scalar function).

The effective annotation is either the method's own attribute or, when the method carries none, the declaring type's attribute — never a merge of the two. A method attribute therefore replaces the type attribute entirely: when it leaves IsAggregate unset, the function is a scalar even if the declaring type is marked as an aggregate, and Name/Schema do not inherit either.

public bool IsAggregate { get; set; }

Property Value

bool

Name

The SQL function name. Defaults to the CLR method name when it is not provided (or when the attribute is applied to the declaring type).

public string? Name { get; set; }

Property Value

string

Schema

Optional schema/owner prefix, rendered as schema.name.

public string? Schema { get; set; }

Property Value

string