Interface ISqlServerFunctions
A dialect's surface for the SQL Server-only T-SQL scalar functions that have no cross-provider
analog (the string functions PATINDEX/QUOTENAME/SOUNDEX/DIFFERENCE/
STRING_ESCAPE/UNICODE/NCHAR/FORMAT, the trigonometric functions, the
date functions DATENAME/DATE_BUCKET and the clock/offset/*FROMPARTS family,
the binary/system functions HASHBYTES/NEWSEQUENTIALID, the
CHECKSUM/COMPRESS/RAND/STUFF scalars, the metadata functions
(COL_LENGTH/OBJECT_ID/DB_ID/SCHEMA_NAME/FILE_ID/
ISDATE/STR/FORMATMESSAGE and the rest of the A–D metadata families) and the
SQL/JSON constructors/aggregates/predicates). The
predicate and the renderer live on one object, so a name the dialect reports as supported always
has a rendering; null is the capability being absent, which makes every other
provider reject the members with a clear message.
public interface ISqlServerFunctions
- Extension Methods
Remarks
Unlike IScalarFunctions, this object is provider-specific and is only reached from the SqlServerFunctions members; a name the provider cannot express is gated per function rather than by a family flag.
Properties
SupportsSessionIdentity
True when the dialect also exposes the SQL Server session/server identity functions
(server_name(), host_id, host_name, app_name,
suser_name, original_login) through its
SessionInfoFunctions renderer. The default is false, so
an external ISqlServerFunctions written for the T-SQL scalar library alone does not
silently gain the identity surface.
bool SupportsSessionIdentity { get; }
Property Value
Methods
GetUnsupportedReason(string)
The reason the SQL Server-only function name is unavailable on this
dialect's declared state (for example a function that requires a later major version), or
null when the name is supported or the dialect has no version-specific
answer. The caller shows this reason instead of its generic "not supported" message, so a
version-gated name fails closed with the required and the declared major version. Declared as
a default interface method returning null so an external
ISqlServerFunctions written before the member existed keeps its previous
behaviour.
string? GetUnsupportedReason(string name)
Parameters
namestringThe CLR method name of the SqlServerFunctions member.
Returns
Render(string, IReadOnlyList<string>)
Renders the SQL Server-only function name over the already-rendered
args. name is the CLR method name of the
SqlServerFunctions member (for example patindex, json_object).
string Render(string name, IReadOnlyList<string> args)
Parameters
namestringargsIReadOnlyList<string>
Returns
RenderBit(string, string, string, string?, string?)
Renders a SQL Server bit-manipulation call (LEFT_SHIFT, RIGHT_SHIFT,
BIT_COUNT, GET_BIT, SET_BIT). The SQL depends on the operand's own type, so
the caller passes the T-SQL operand type (tinyint/smallint/int/bigint)
rather than expecting the string-only Render(string, IReadOnlyList<string>) to guess it: the operand and the
shift/offset are cast inside the call and a NULL argument yields a typed NULL of the result type,
because a bare left_shift(null, …) is Msg 8116. Declared as a default interface method so
an external ISqlServerFunctions written before the member existed keeps compiling
and rejects the family explicitly instead of emitting SQL it cannot render.
string RenderBit(string name, string operand, string operandType, string? amount, string? value)
Parameters
namestringThe CLR method name of the SqlServerFunctions member.
operandstringThe rendered operand expression.
operandTypestringThe T-SQL type of the operand.
amountstringThe rendered shift or bit-offset expression, or null.
valuestringThe rendered
SET_BITbit value, or null when omitted.
Returns
- string
The complete T-SQL expression.
Supports(string)
True when the SQL Server-only function name can be rendered.
bool Supports(string name)
Parameters
namestring