Table of Contents

Class Sql

Namespace
LinqToDB
Assembly
linq2db.dll
public static class Sql
Inheritance
Sql

Fields

GroupBy

public static Sql.IGroupBy GroupBy

Field Value

Sql.IGroupBy

Properties

CurrentTimestamp

[Sql.Property("CURRENT_TIMESTAMP", ServerSideOnly = true, CanBeNull = false)]
[Sql.Property("Firebird", "LOCALTIMESTAMP", ServerSideOnly = true, CanBeNull = false)]
[Sql.Property("Informix", "CURRENT", ServerSideOnly = true, CanBeNull = false)]
[Sql.Property("Access", "Now", ServerSideOnly = true, CanBeNull = false)]
[Sql.Function("SqlCe", "GetDate", ServerSideOnly = true, CanBeNull = false)]
[Sql.Function("Sybase", "GetDate", ServerSideOnly = true, CanBeNull = false)]
[Sql.Function("ClickHouse", "now", ServerSideOnly = true, CanBeNull = false)]
public static DateTime CurrentTimestamp { get; }

Property Value

DateTime

CurrentTimestamp2

[Sql.Property("CURRENT_TIMESTAMP", CanBeNull = false)]
[Sql.Property("Informix", "CURRENT", CanBeNull = false)]
[Sql.Property("Access", "Now", CanBeNull = false)]
[Sql.Function("SqlCe", "GetDate", CanBeNull = false)]
[Sql.Function("Sybase", "GetDate", CanBeNull = false)]
[Sql.Function("ClickHouse", "now", CanBeNull = false)]
public static DateTime CurrentTimestamp2 { get; }

Property Value

DateTime

CurrentTimestampUtc

[Sql.Function("SqlServer", "SYSUTCDATETIME", ServerSideOnly = true, CanBeNull = false)]
[Sql.Function("Sybase", "GETUTCDATE", ServerSideOnly = true, CanBeNull = false)]
[Sql.Expression("SQLite", "DATETIME('now')", ServerSideOnly = true, CanBeNull = false)]
[Sql.Function("MySql", "UTC_TIMESTAMP", ServerSideOnly = true, CanBeNull = false)]
[Sql.Expression("PostgreSQL", "timezone('UTC', now())", ServerSideOnly = true, CanBeNull = false)]
[Sql.Expression("DB2", "CURRENT TIMESTAMP - CURRENT TIMEZONE", ServerSideOnly = true, CanBeNull = false, Precedence = 70)]
[Sql.Expression("Oracle", "SYS_EXTRACT_UTC(SYSTIMESTAMP)", ServerSideOnly = true, CanBeNull = false, Precedence = 60)]
[Sql.Property("SapHana", "CURRENT_UTCTIMESTAMP", ServerSideOnly = true, CanBeNull = false, Precedence = 60)]
[Sql.Expression("Informix", "datetime(1970-01-01 00:00:00) year to second + (dbinfo('utc_current')/86400)::int::char(9)::interval day(9) to day + (mod(dbinfo('utc_current'), 86400))::char(5)::interval second(5) to second", ServerSideOnly = true, CanBeNull = false, Precedence = 60)]
[Sql.Expression("ClickHouse", "now('UTC')", ServerSideOnly = true, CanBeNull = false)]
public static DateTime CurrentTimestampUtc { get; }

Property Value

DateTime

CurrentTzTimestamp

[Sql.Function("SqlServer", "SYSDATETIMEOFFSET", ServerSideOnly = true, CanBeNull = false)]
[Sql.Function("PostgreSQL", "now", ServerSideOnly = true, CanBeNull = false)]
[Sql.Property("Oracle", "SYSTIMESTAMP", ServerSideOnly = true, CanBeNull = false, Precedence = 60)]
[Sql.Function("ClickHouse", "now", ServerSideOnly = true, CanBeNull = false)]
public static DateTimeOffset CurrentTzTimestamp { get; }

Property Value

DateTimeOffset

DateFirst

[Sql.Property("@@DATEFIRST", CanBeNull = false)]
[Sql.Property("ClickHouse", "1", CanBeNull = false)]
public static int DateFirst { get; }

Property Value

int

Ext

public static Sql.ISqlExtension? Ext { get; }

Property Value

Sql.ISqlExtension

Methods

Abs(decimal?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Abs(decimal? value)

Parameters

value decimal?

Returns

decimal?

Abs(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Abs(double? value)

Parameters

value double?

Returns

double?

Abs(short?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static short? Abs(short? value)

Parameters

value short?

Returns

short?

Abs(int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Abs(int? value)

Parameters

value int?

Returns

int?

Abs(long?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static long? Abs(long? value)

Parameters

value long?

Returns

long?

Abs(sbyte?)

[CLSCompliant(false)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static sbyte? Abs(sbyte? value)

Parameters

value sbyte?

Returns

sbyte?

Abs(float?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static float? Abs(float? value)

Parameters

value float?

Returns

float?

Acos(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Acos(double? value)

Parameters

value double?

Returns

double?

AliasExpr()

Useful for specifying place of alias when using FromSql<TEntity>(IDataContext, RawSqlString, params object?[]) method.

[Sql.Extension("", BuilderType = typeof(Sql.TableSourceBuilder), ServerSideOnly = true)]
public static ISqlExpression AliasExpr()

Returns

ISqlExpression

ISqlExpression which is Alias Placeholder.

Examples

The following FromSql<TEntity>(IDataContext, RawSqlString, params object?[]) calls are equivalent.

db.FromSql<int>($"select 1 as value from TableA {Sql.AliasExpr()}")
db.FromSql<int>($"select 1 as value from TableA")

Remarks

If FromSql<TEntity>(IDataContext, RawSqlString, params object?[]) contains at least one AliasExpr(), automatic alias for the query will be not generated.

AllColumns()

Generates '*'.

[Sql.Expression("*", ServerSideOnly = true, CanBeNull = false, Precedence = 100)]
public static object?[] AllColumns()

Returns

object[]

AsNotNull<T>(T)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, CanBeNull = false)]
public static T AsNotNull<T>(T value)

Parameters

value T

Returns

T

Type Parameters

T

AsNotNullable<T>(T)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, CanBeNull = false)]
public static T AsNotNullable<T>(T value)

Parameters

value T

Returns

T

Type Parameters

T

AsNullable<T>(T)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, CanBeNull = true)]
public static T AsNullable<T>(T value)

Parameters

value T

Returns

T

Type Parameters

T

AsSql<T>(T)

Enforces generating SQL even if an expression can be calculated locally.

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, ServerSideOnly = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T AsSql<T>(T obj)

Parameters

obj T

Expression to generate SQL.

Returns

T

Returns 'obj'.

Type Parameters

T

Asin(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Asin(double? value)

Parameters

value double?

Returns

double?

Atan(double?)

[Sql.Function("Access", "Atn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Atan(double? value)

Parameters

value double?

Returns

double?

Atan2(double?, double?)

[CLSCompliant(false)]
[Sql.Function("SqlServer", "Atn2", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("DB2", "Atan2", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SqlCe", "Atn2", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Sybase", "Atn2", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Atan2(double? x, double? y)

Parameters

x double?
y double?

Returns

double?

Between<T>(T?, T?, T?)

[Sql.Extension("", "", PreferServerSide = true, IsPredicate = true, BuilderType = typeof(Sql.BetweenBuilder))]
public static bool Between<T>(this T? value, T? low, T? high) where T : struct, IComparable

Parameters

value T?
low T?
high T?

Returns

bool

Type Parameters

T

Between<T>(T, T, T)

[Sql.Extension("", "", PreferServerSide = true, IsPredicate = true, BuilderType = typeof(Sql.BetweenBuilder))]
public static bool Between<T>(this T value, T low, T high) where T : IComparable

Parameters

value T
low T
high T

Returns

bool

Type Parameters

T

Ceiling(decimal?)

[Sql.Function("Informix", "Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Oracle", "Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Ceiling(decimal? value)

Parameters

value decimal?

Returns

decimal?

Ceiling(double?)

[Sql.Function("Informix", "Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Oracle", "Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Ceiling(double? value)

Parameters

value double?

Returns

double?

CharIndex(char?, string?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("DB2", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("MySql", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Locate", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "positionUTF8", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Firebird", "Position", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? CharIndex(char? value, string? str)

Parameters

value char?
str string

Returns

int?

CharIndex(char?, string?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("DB2", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("MySql", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Locate", new int[] { 1, 0, 2 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "positionUTF8({1}, {0}, toUInt32({2}))", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Firebird", "Position", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? CharIndex(char? value, string? str, int? start)

Parameters

value char?
str string
start int?

Returns

int?

CharIndex(string?, string?)

[CLSCompliant(false)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("DB2", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("MySql", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Locate", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Firebird", "Position", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "positionUTF8", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? CharIndex(string? substring, string? str)

Parameters

substring string
str string

Returns

int?

CharIndex(string?, string?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("DB2", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("MySql", "Locate", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Firebird", "Position", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "positionUTF8({1}, {0}, toUInt32({2}))", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SapHana", "Locate(Substring({1},{2} + 1),{0}) + {2}", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? CharIndex(string? substring, string? str, int? start)

Parameters

substring string
str string
start int?

Returns

int?

Collate(string?, string)

Apply collation to a string expression.

[Sql.Extension("", ServerSideOnly = true, BuilderType = typeof(Sql.DB2LUWCollationBuilder), Configuration = "DB2.LUW")]
[Sql.Extension("", ServerSideOnly = true, BuilderType = typeof(Sql.PostgreSQLCollationBuilder), Configuration = "PostgreSQL")]
[Sql.Extension("", ServerSideOnly = true, BuilderType = typeof(Sql.NamedCollationBuilder))]
public static string? Collate(this string? expr, string collation)

Parameters

expr string

Expression to apply collation to.

collation string

Collation to apply.

Returns

string

Expression with specified collation.

Remarks

Server-side only, does not perform validation on collation name beyond simple valid character checks.

Concat(params object[])

public static string Concat(params object[] args)

Parameters

args object[]

Returns

string

Concat(params string[])

public static string Concat(params string[] args)

Parameters

args string[]

Returns

string

ConcatStrings(string, params string?[])

Concatenates NOT NULL strings, using the specified separator between each member.

[Sql.Extension("SqlServer.2022", "CONCAT_WS({separator}, {argument, ', '})", BuilderType = typeof(Sql.CommonConcatWsArgumentsBuilder), BuilderValue = "ISNULL({0}, '')")]
[Sql.Extension("SqlServer.2019", "CONCAT_WS({separator}, {argument, ', '})", BuilderType = typeof(Sql.CommonConcatWsArgumentsBuilder), BuilderValue = "ISNULL({0}, '')")]
[Sql.Extension("SqlServer.2017", "CONCAT_WS({separator}, {argument, ', '})", BuilderType = typeof(Sql.CommonConcatWsArgumentsBuilder), BuilderValue = "ISNULL({0}, '')")]
[Sql.Extension("PostgreSQL", "CONCAT_WS({separator}, {argument, ', '})", BuilderType = typeof(Sql.CommonConcatWsArgumentsBuilder), BuilderValue = null)]
[Sql.Extension("MySql", "CONCAT_WS({separator}, {argument, ', '})", BuilderType = typeof(Sql.CommonConcatWsArgumentsBuilder), BuilderValue = null)]
[Sql.Extension("SqlServer", "", BuilderType = typeof(Sql.OldSqlServerConcatWsBuilder))]
[Sql.Extension("SQLite", "", BuilderType = typeof(Sql.SqliteConcatWsBuilder))]
[Sql.Extension("ClickHouse", "arrayStringConcat([{arguments, ', '}], {separator})", CanBeNull = false)]
public static string ConcatStrings(string separator, params string?[] arguments)

Parameters

separator string

The string to use as a separator. separator is included in the returned string only if arguments has more than one element.

arguments string[]

A collection that contains the strings to concatenate.

Returns

string

Convert2<TTo, TFrom>(TTo, TFrom)

[CLSCompliant(false)]
[Sql.Function("Convert", new int[] { 0, 1 }, IsPure = true, IsNullable = Sql.IsNullableType.SameAsSecondParameter)]
[Sql.Function("$Convert$", new int[] { 2, 3, 1 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.SameAsSecondParameter, Configuration = "ClickHouse")]
public static TTo Convert2<TTo, TFrom>(TTo to, TFrom from)

Parameters

to TTo
from TFrom

Returns

TTo

Type Parameters

TTo
TFrom

Convert<TTo, TFrom>(TTo, TFrom)

[CLSCompliant(false)]
[Sql.Function("Convert", new int[] { 0, 1 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.SameAsSecondParameter)]
[Sql.Function("$Convert$", new int[] { 2, 3, 1 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.SameAsSecondParameter, Configuration = "ClickHouse")]
public static TTo Convert<TTo, TFrom>(TTo to, TFrom from)

Parameters

to TTo
from TFrom

Returns

TTo

Type Parameters

TTo
TFrom

Convert<TTo, TFrom>(TTo, TFrom, int)

[CLSCompliant(false)]
[Sql.Function("Convert", new int[] { 0, 1, 2 }, ServerSideOnly = true, IsNullable = Sql.IsNullableType.SameAsSecondParameter)]
public static TTo Convert<TTo, TFrom>(TTo to, TFrom from, int format)

Parameters

to TTo
from TFrom
format int

Returns

TTo

Type Parameters

TTo
TFrom

Convert<TTo, TFrom>(TFrom)

[CLSCompliant(false)]
[Sql.Function("$Convert$", new int[] { 1, 2, 0 }, IsPure = true)]
public static TTo Convert<TTo, TFrom>(TFrom obj)

Parameters

obj TFrom

Returns

TTo

Type Parameters

TTo
TFrom

Cos(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Cos(double? value)

Parameters

value double?

Returns

double?

Cosh(double?)

[Sql.Function("ClickHouse", "cosh", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Cosh(double? value)

Parameters

value double?

Returns

double?

Cot(double?)

[Sql.Expression("ClickHouse", "1/tan({0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 80)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Cot(double? value)

Parameters

value double?

Returns

double?

DateAdd(DateParts, double?, DateTimeOffset?)

[Sql.Extension("DateAdd", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateOffsetAddBuilder))]
[Sql.Extension("PostgreSQL", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateOffsetAddBuilderPostgreSQL))]
[Sql.Extension("Oracle", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderOracle))]
[Sql.Extension("DB2", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderDB2))]
[Sql.Extension("Informix", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderInformix))]
[Sql.Extension("MySql", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderMySql))]
[Sql.Extension("SQLite", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderSQLite))]
[Sql.Extension("Access", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderAccess))]
[Sql.Extension("SapHana", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderSapHana))]
[Sql.Extension("Firebird", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderFirebird))]
[Sql.Extension("ClickHouse", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderClickHouse))]
public static DateTimeOffset? DateAdd(Sql.DateParts part, double? number, DateTimeOffset? date)

Parameters

part Sql.DateParts
number double?
date DateTimeOffset?

Returns

DateTimeOffset?

DateAdd(DateParts, double?, DateTime?)

[Sql.Extension("DateAdd", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilder))]
[Sql.Extension("Oracle", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderOracle))]
[Sql.Extension("DB2", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderDB2))]
[Sql.Extension("Informix", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderInformix))]
[Sql.Extension("PostgreSQL", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderPostgreSQL))]
[Sql.Extension("MySql", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderMySql))]
[Sql.Extension("SQLite", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderSQLite))]
[Sql.Extension("Access", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderAccess))]
[Sql.Extension("SapHana", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderSapHana))]
[Sql.Extension("Firebird", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderFirebird))]
[Sql.Extension("ClickHouse", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DateAddBuilderClickHouse))]
public static DateTime? DateAdd(Sql.DateParts part, double? number, DateTime? date)

Parameters

part Sql.DateParts
number double?
date DateTime?

Returns

DateTime?

DateDiff(DateParts, DateTimeOffset?, DateTimeOffset?)

[CLSCompliant(false)]
[Sql.Extension("DateDiff", BuilderType = typeof(Sql.DateDiffBuilder))]
[Sql.Extension("MySql", "TIMESTAMPDIFF", BuilderType = typeof(Sql.DateDiffBuilder))]
[Sql.Extension("DB2", "", BuilderType = typeof(Sql.DateDiffBuilderDB2))]
[Sql.Extension("SapHana", "", BuilderType = typeof(Sql.DateDiffBuilderSapHana))]
[Sql.Extension("SQLite", "", BuilderType = typeof(Sql.DateDiffBuilderSQLite))]
[Sql.Extension("PostgreSQL", "", BuilderType = typeof(Sql.DateDiffBuilderPostgreSql))]
[Sql.Extension("Access", "", BuilderType = typeof(Sql.DateDiffBuilderAccess))]
[Sql.Extension("ClickHouse", "", BuilderType = typeof(Sql.DateDiffBuilderClickHouse))]
public static int? DateDiff(Sql.DateParts part, DateTimeOffset? startDate, DateTimeOffset? endDate)

Parameters

part Sql.DateParts
startDate DateTimeOffset?
endDate DateTimeOffset?

Returns

int?

DateDiff(DateParts, DateTime?, DateTime?)

[CLSCompliant(false)]
[Sql.Extension("DateDiff", BuilderType = typeof(Sql.DateDiffBuilder))]
[Sql.Extension("MySql", "TIMESTAMPDIFF", BuilderType = typeof(Sql.DateDiffBuilder))]
[Sql.Extension("DB2", "", BuilderType = typeof(Sql.DateDiffBuilderDB2))]
[Sql.Extension("SapHana", "", BuilderType = typeof(Sql.DateDiffBuilderSapHana))]
[Sql.Extension("SQLite", "", BuilderType = typeof(Sql.DateDiffBuilderSQLite))]
[Sql.Extension("Oracle", "", BuilderType = typeof(Sql.DateDiffBuilderOracle))]
[Sql.Extension("PostgreSQL", "", BuilderType = typeof(Sql.DateDiffBuilderPostgreSql))]
[Sql.Extension("Access", "", BuilderType = typeof(Sql.DateDiffBuilderAccess))]
[Sql.Extension("ClickHouse", "", BuilderType = typeof(Sql.DateDiffBuilderClickHouse))]
public static int? DateDiff(Sql.DateParts part, DateTime? startDate, DateTime? endDate)

Parameters

part Sql.DateParts
startDate DateTime?
endDate DateTime?

Returns

int?

DatePart(DateParts, DateTimeOffset?)

[Sql.Extension("DatePart", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilder))]
[Sql.Extension("DB2", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderDB2))]
[Sql.Extension("Informix", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderInformix))]
[Sql.Extension("MySql", "Extract({part} from {date})", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderMySql))]
[Sql.Extension("PostgreSQL", "Cast(Floor(Extract({part} from {date})) as int)", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderPostgre))]
[Sql.Extension("Firebird", "Cast(Floor(Extract({part} from {date})) as int)", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderFirebird))]
[Sql.Extension("SQLite", "Cast(StrFTime('%{part}', {date}) as int)", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderSqLite))]
[Sql.Extension("Access", "DatePart('{part}', {date})", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderAccess))]
[Sql.Extension("SapHana", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderSapHana))]
[Sql.Extension("Oracle", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderOracle))]
[Sql.Extension("ClickHouse", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderClickHouse))]
public static int? DatePart(Sql.DateParts part, DateTimeOffset? date)

Parameters

part Sql.DateParts
date DateTimeOffset?

Returns

int?

DatePart(DateParts, DateTime?)

[Sql.Extension("DatePart", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilder))]
[Sql.Extension("DB2", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderDB2))]
[Sql.Extension("Informix", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderInformix))]
[Sql.Extension("MySql", "Extract({part} from {date})", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderMySql))]
[Sql.Extension("PostgreSQL", "Cast(Floor(Extract({part} from {date})) as int)", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderPostgre))]
[Sql.Extension("Firebird", "Cast(Floor(Extract({part} from {date})) as int)", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderFirebird))]
[Sql.Extension("SQLite", "Cast(StrFTime('%{part}', {date}) as int)", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderSqLite))]
[Sql.Extension("Access", "DatePart('{part}', {date})", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderAccess))]
[Sql.Extension("SapHana", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderSapHana))]
[Sql.Extension("Oracle", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderOracle))]
[Sql.Extension("ClickHouse", "", ServerSideOnly = false, PreferServerSide = false, BuilderType = typeof(Sql.DatePartBuilderClickHouse))]
public static int? DatePart(Sql.DateParts part, DateTime? date)

Parameters

part Sql.DateParts
date DateTime?

Returns

int?

DateToTime(DateTime?)

[Sql.Expression("{0}", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static TimeSpan? DateToTime(DateTime? date)

Parameters

date DateTime?

Returns

TimeSpan?

Default<T>()

Generates 'DEFAULT' keyword, usable in inserts.

[Sql.Expression("DEFAULT", ServerSideOnly = true)]
public static T Default<T>()

Returns

T

Type Parameters

T

Degrees(decimal?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Degrees(decimal? value)

Parameters

value decimal?

Returns

decimal?

Degrees(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Degrees(double? value)

Parameters

value double?

Returns

double?

Degrees(short?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static short? Degrees(short? value)

Parameters

value short?

Returns

short?

Degrees(int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Degrees(int? value)

Parameters

value int?

Returns

int?

Degrees(long?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static long? Degrees(long? value)

Parameters

value long?

Returns

long?

Degrees(sbyte?)

[CLSCompliant(false)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static sbyte? Degrees(sbyte? value)

Parameters

value sbyte?

Returns

sbyte?

Degrees(float?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static float? Degrees(float? value)

Parameters

value float?

Returns

float?

Exp(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Exp(double? value)

Parameters

value double?

Returns

double?

Expr<T>(RawSqlString, params object[])

[Sql.Extension("", BuilderType = typeof(Sql.ExprBuilder), ServerSideOnly = true)]
public static T Expr<T>(RawSqlString sql, params object[] parameters)

Parameters

sql RawSqlString
parameters object[]

Returns

T

Type Parameters

T

FieldExpr(object)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static ISqlExpression FieldExpr(object fieldExpr)

Parameters

fieldExpr object

Returns

ISqlExpression

FieldExpr(object, bool)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static ISqlExpression FieldExpr(object fieldExpr, bool qualified)

Parameters

fieldExpr object
qualified bool

Returns

ISqlExpression

FieldExpr<T, TV>(ITable<T>, Expression<Func<T, TV>>)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilderDirect), ServerSideOnly = false)]
public static ISqlExpression FieldExpr<T, TV>(ITable<T> table, Expression<Func<T, TV>> fieldExpr) where T : notnull

Parameters

table ITable<T>
fieldExpr Expression<Func<T, TV>>

Returns

ISqlExpression

Type Parameters

T
TV

FieldExpr<T, TV>(ITable<T>, Expression<Func<T, TV>>, bool)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilderDirect), ServerSideOnly = false)]
public static ISqlExpression FieldExpr<T, TV>(ITable<T> table, Expression<Func<T, TV>> fieldExpr, bool qualified) where T : notnull

Parameters

table ITable<T>
fieldExpr Expression<Func<T, TV>>
qualified bool

Returns

ISqlExpression

Type Parameters

T
TV

FieldName(object)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static string FieldName(object fieldExpr)

Parameters

fieldExpr object

Returns

string

FieldName(object, bool)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static string FieldName(object fieldExpr, bool qualified)

Parameters

fieldExpr object
qualified bool

Returns

string

FieldName<T>(ITable<T>, Expression<Func<T, object>>)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilderDirect), ServerSideOnly = false)]
public static string FieldName<T>(ITable<T> table, Expression<Func<T, object>> fieldExpr) where T : notnull

Parameters

table ITable<T>
fieldExpr Expression<Func<T, object>>

Returns

string

Type Parameters

T

FieldName<T>(ITable<T>, Expression<Func<T, object>>, bool)

[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilderDirect), ServerSideOnly = false)]
public static string FieldName<T>(ITable<T> table, Expression<Func<T, object>> fieldExpr, bool qualified) where T : notnull

Parameters

table ITable<T>
fieldExpr Expression<Func<T, object>>
qualified bool

Returns

string

Type Parameters

T

Floor(decimal?)

[Sql.Function("Access", "Int", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Floor(decimal? value)

Parameters

value decimal?

Returns

decimal?

Floor(double?)

[Sql.Function("Access", "Int", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Floor(double? value)

Parameters

value double?

Returns

double?

GetDate()

[Sql.Property("CURRENT_TIMESTAMP", CanBeNull = false)]
[Sql.Property("Informix", "CURRENT", CanBeNull = false)]
[Sql.Property("Access", "Now", CanBeNull = false)]
[Sql.Function("ClickHouse", "now", CanBeNull = false)]
public static DateTime GetDate()

Returns

DateTime

Grouping(params object[])

[Sql.Extension("GROUPING({fields, ', '})", ServerSideOnly = true, CanBeNull = false, IsAggregate = true)]
public static int Grouping(params object[] fields)

Parameters

fields object[]

Returns

int

IsDistinctFrom<T>(T, T?)

[Sql.Extension(typeof(Sql.IsDistinctBuilder), ServerSideOnly = false, PreferServerSide = false)]
public static bool IsDistinctFrom<T>(this T value, T? other) where T : struct

Parameters

value T
other T?

Returns

bool

Type Parameters

T

IsDistinctFrom<T>(T, T)

[Sql.Extension(typeof(Sql.IsDistinctBuilder), ServerSideOnly = false, PreferServerSide = false)]
public static bool IsDistinctFrom<T>(this T value, T other)

Parameters

value T
other T

Returns

bool

Type Parameters

T

IsNotDistinctFrom<T>(T, T?)

[Sql.Extension(typeof(Sql.IsDistinctBuilder), Expression = "NOT", ServerSideOnly = false, PreferServerSide = false)]
public static bool IsNotDistinctFrom<T>(this T value, T? other) where T : struct

Parameters

value T
other T?

Returns

bool

Type Parameters

T

IsNotDistinctFrom<T>(T, T)

[Sql.Extension(typeof(Sql.IsDistinctBuilder), Expression = "NOT", ServerSideOnly = false, PreferServerSide = false)]
public static bool IsNotDistinctFrom<T>(this T value, T other)

Parameters

value T
other T

Returns

bool

Type Parameters

T

Left(string?, int?)

[Sql.Function(PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SQLite", "LeftStr", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "leftUTF8", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Left(string? str, int? length)

Parameters

str string
length int?

Returns

string

Length(byte[]?)

[Sql.Function(PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Access", "Len", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Firebird", "Octet_Length", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("SqlServer", "DataLength", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("SqlCe", "DataLength", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Sybase", "DataLength", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
public static int? Length(byte[]? value)

Parameters

value byte[]

Returns

int?

Length(Binary?)

[Sql.Function(PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Access", "Len", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Firebird", "Octet_Length", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("SqlServer", "DataLength", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("SqlCe", "DataLength", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Sybase", "DataLength", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
public static int? Length(Binary? value)

Parameters

value Binary

Returns

int?

Length(string?)

[Sql.Function(PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Access", "Len", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Firebird", "Char_Length", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("SqlServer", "Len", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("SqlCe", "Len", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Sybase", "Len", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("MySql", "Char_Length", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("Informix", "CHAR_LENGTH", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("ClickHouse", "CHAR_LENGTH", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("DB2.LUW", "CHARACTER_LENGTH({0},CODEUNITS32)", PreferServerSide = true, IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
public static int? Length(string? str)

Parameters

str string

Returns

int?

Like(string?, string?)

[Sql.Function(ServerSideOnly = true, IsPredicate = true)]
public static bool Like(string? matchExpression, string? pattern)

Parameters

matchExpression string
pattern string

Returns

bool

Like(string?, string?, char?)

[Sql.Function(ServerSideOnly = true, IsPredicate = true)]
public static bool Like(string? matchExpression, string? pattern, char? escapeCharacter)

Parameters

matchExpression string
pattern string
escapeCharacter char?

Returns

bool

Log(decimal?)

[Sql.Function("Informix", "LogN", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Oracle", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Firebird", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("PostgreSQL", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Log(decimal? value)

Parameters

value decimal?

Returns

decimal?

Log(decimal?, decimal?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "Log({1}) / Log({0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 80)]
public static decimal? Log(decimal? newBase, decimal? value)

Parameters

newBase decimal?
value decimal?

Returns

decimal?

Log(double?)

[Sql.Function("Informix", "LogN", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Oracle", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Firebird", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("PostgreSQL", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SapHana", "Ln", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Log(double? value)

Parameters

value double?

Returns

double?

Log(double?, double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "Log({1}) / Log({0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 80)]
public static double? Log(double? newBase, double? value)

Parameters

newBase double?
value double?

Returns

double?

Log10(double?)

[Sql.Function("PostgreSQL", "Log", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SapHana", "Log(10,{0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Log10(double? value)

Parameters

value double?

Returns

double?

Lower(string?)

[Sql.Function("$ToLower$", ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Lower(string? str)

Parameters

str string

Returns

string

MakeDateTime(int?, int?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static DateTime? MakeDateTime(int? year, int? month, int? day)

Parameters

year int?
month int?
day int?

Returns

DateTime?

MakeDateTime(int?, int?, int?, int?, int?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static DateTime? MakeDateTime(int? year, int? month, int? day, int? hour, int? minute, int? second)

Parameters

year int?
month int?
day int?
hour int?
minute int?
second int?

Returns

DateTime?

NewGuid()

[Sql.Function("ClickHouse", "generateUUIDv4", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
[Sql.Function("Oracle", "Sys_Guid", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
[Sql.Function("Firebird", "Gen_Uuid", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
[Sql.Function("MySql", "Uuid", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
[Sql.Expression("Sybase", "NewID(1)", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
[Sql.Expression("SapHana", "SYSUUID", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
[Sql.Function("NewID", ServerSideOnly = true, CanBeNull = false, IsPure = false)]
public static Guid NewGuid()

Returns

Guid

NoConvert<T>(T)

[Sql.Extension("", BuilderType = typeof(Sql.NoConvertBuilder), ServerSideOnly = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T NoConvert<T>(T expr)

Parameters

expr T

Returns

T

Type Parameters

T

NotBetween<T>(T?, T?, T?)

[Sql.Extension("", "", PreferServerSide = true, IsPredicate = true, BuilderType = typeof(Sql.NotBetweenBuilder))]
public static bool NotBetween<T>(this T? value, T? low, T? high) where T : struct, IComparable

Parameters

value T?
low T?
high T?

Returns

bool

Type Parameters

T

NotBetween<T>(T, T, T)

[Sql.Extension("", "", PreferServerSide = true, IsPredicate = true, BuilderType = typeof(Sql.NotBetweenBuilder))]
public static bool NotBetween<T>(this T value, T low, T high) where T : IComparable

Parameters

value T
low T
high T

Returns

bool

Type Parameters

T

NullIf<T>(T?, T?)

[Sql.Expression("NULLIF({0}, {1})", PreferServerSide = true)]
[Sql.Expression("Access", "case when {0} = {1} then null else {0} end", PreferServerSide = false)]
[Sql.Expression("SqlCe", "case when {0} = {1} then null else {0} end", PreferServerSide = false)]
public static T? NullIf<T>(T? value, T? compareTo) where T : struct

Parameters

value T?
compareTo T?

Returns

T?

Type Parameters

T

NullIf<T>(T?, T)

[Sql.Expression("NULLIF({0}, {1})", PreferServerSide = true)]
[Sql.Expression("Access", "case when {0} = {1} then null else {0} end", PreferServerSide = false)]
[Sql.Expression("SqlCe", "case when {0} = {1} then null else {0} end", PreferServerSide = false)]
public static T? NullIf<T>(T? value, T compareTo) where T : struct

Parameters

value T?
compareTo T

Returns

T?

Type Parameters

T

NullIf<T>(T?, T?)

[Sql.Expression("NULLIF({0}, {1})", PreferServerSide = true)]
[Sql.Expression("Access", "case when {0} = {1} then null else {0} end", PreferServerSide = false)]
[Sql.Expression("SqlCe", "case when {0} = {1} then null else {0} end", PreferServerSide = false)]
public static T? NullIf<T>(T? value, T? compareTo) where T : class

Parameters

value T
compareTo T

Returns

T

Type Parameters

T

Overlaps<T1, T2, T3, T4>(SqlRow<T1, T2>, SqlRow<T3, T4>)

[Sql.Extension("", "", IsPredicate = true, ServerSideOnly = true, Precedence = 50, BuilderType = typeof(Sql.OverlapsBuilder))]
public static bool Overlaps<T1, T2, T3, T4>(this Sql.SqlRow<T1, T2> thisRow, Sql.SqlRow<T3, T4> other)

Parameters

thisRow Sql.SqlRow<T1, T2>
other Sql.SqlRow<T3, T4>

Returns

bool

Type Parameters

T1
T2
T3
T4

PadLeft(string?, int?, char?)

[Sql.Function(Name = "LPad", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "leftPadUTF8({0}, toUInt32({1}), {2})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? PadLeft(string? str, int? length, char? paddingChar)

Parameters

str string
length int?
paddingChar char?

Returns

string

PadRight(string?, int?, char?)

[Sql.Function(Name = "RPad", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "rightPadUTF8({0}, toUInt32({1}), {2})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? PadRight(string? str, int? length, char? paddingChar)

Parameters

str string
length int?
paddingChar char?

Returns

string

Power(double?, double?)

[Sql.Expression("Access", "{0} ^ {1}", Precedence = 80, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Power(double? x, double? y)

Parameters

x double?
y double?

Returns

double?

Property<T>(object?, string)

Allows access to entity property via name. Property can be dynamic or non-dynamic.

public static T Property<T>(object? entity, string propertyName)

Parameters

entity object

The entity.

propertyName string

Name of the property.

Returns

T

Type Parameters

T

Property type.

Exceptions

LinqException

'Property' is only server-side method.

Replace(string?, char?, char?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Sybase", "Str_Replace", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "replaceAll", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Replace(string? str, char? oldValue, char? newValue)

Parameters

str string
oldValue char?
newValue char?

Returns

string

Replace(string?, string?, string?)

[Sql.Function("$Replace$", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Replace(string? str, string? oldValue, string? newValue)

Parameters

str string
oldValue string
newValue string

Returns

string

Reverse(string?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "reverseUTF8", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Reverse(string? str)

Parameters

str string

Returns

string

Right(string?, int?)

[Sql.Function(PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SQLite", "RightStr", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "rightUTF8", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Right(string? str, int? length)

Parameters

str string
length int?

Returns

string

Round(decimal?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Round(decimal? value)

Parameters

value decimal?

Returns

decimal?

Round(decimal?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Round(decimal? value, int? precision)

Parameters

value decimal?
precision int?

Returns

decimal?

Round(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Round(double? value)

Parameters

value double?

Returns

double?

Round(double?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Round(double? value, int? precision)

Parameters

value double?
precision int?

Returns

double?

RoundToEven(decimal?)

[Sql.Function(IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("ClickHouse", "roundBankers", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
public static decimal? RoundToEven(decimal? value)

Parameters

value decimal?

Returns

decimal?

RoundToEven(decimal?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "roundBankers", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? RoundToEven(decimal? value, int? precision)

Parameters

value decimal?
precision int?

Returns

decimal?

RoundToEven(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Function("ClickHouse", "roundBankers", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
public static double? RoundToEven(double? value)

Parameters

value double?

Returns

double?

RoundToEven(double?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "roundBankers", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? RoundToEven(double? value, int? precision)

Parameters

value double?
precision int?

Returns

double?

Row<T1, T2>(T1, T2)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, T2> Row<T1, T2>(T1 value1, T2 value2)

Parameters

value1 T1
value2 T2

Returns

Sql.SqlRow<T1, T2>

Type Parameters

T1
T2

Row<T1, T2, T3>(T1, T2, T3)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, Sql.SqlRow<T2, T3>> Row<T1, T2, T3>(T1 value1, T2 value2, T3 value3)

Parameters

value1 T1
value2 T2
value3 T3

Returns

Sql.SqlRow<T1, Sql.SqlRow<T2, T3>>

Type Parameters

T1
T2
T3

Row<T1, T2, T3, T4>(T1, T2, T3, T4)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, T4>>> Row<T1, T2, T3, T4>(T1 value1, T2 value2, T3 value3, T4 value4)

Parameters

value1 T1
value2 T2
value3 T3
value4 T4

Returns

Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, T4>>>

Type Parameters

T1
T2
T3
T4

Row<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, T5>>>> Row<T1, T2, T3, T4, T5>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5)

Parameters

value1 T1
value2 T2
value3 T3
value4 T4
value5 T5

Returns

Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, T5>>>>

Type Parameters

T1
T2
T3
T4
T5

Row<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, Sql.SqlRow<T5, T6>>>>> Row<T1, T2, T3, T4, T5, T6>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6)

Parameters

value1 T1
value2 T2
value3 T3
value4 T4
value5 T5
value6 T6

Returns

Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, Sql.SqlRow<T5, T6>>>>>

Type Parameters

T1
T2
T3
T4
T5
T6

Row<T1, T2, T3, T4, T5, T6, T7>(T1, T2, T3, T4, T5, T6, T7)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, Sql.SqlRow<T5, Sql.SqlRow<T6, T7>>>>>> Row<T1, T2, T3, T4, T5, T6, T7>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7)

Parameters

value1 T1
value2 T2
value3 T3
value4 T4
value5 T5
value6 T6
value7 T7

Returns

Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, Sql.SqlRow<T5, Sql.SqlRow<T6, T7>>>>>>

Type Parameters

T1
T2
T3
T4
T5
T6
T7

Row<T1, T2, T3, T4, T5, T6, T7, T8>(T1, T2, T3, T4, T5, T6, T7, T8)

[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, Sql.SqlRow<T5, Sql.SqlRow<T6, Sql.SqlRow<T7, T8>>>>>>> Row<T1, T2, T3, T4, T5, T6, T7, T8>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8)

Parameters

value1 T1
value2 T2
value3 T3
value4 T4
value5 T5
value6 T6
value7 T7
value8 T8

Returns

Sql.SqlRow<T1, Sql.SqlRow<T2, Sql.SqlRow<T3, Sql.SqlRow<T4, Sql.SqlRow<T5, Sql.SqlRow<T6, Sql.SqlRow<T7, T8>>>>>>>

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

Sign(decimal?)

[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(decimal? value)

Parameters

value decimal?

Returns

int?

Sign(double?)

[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(double? value)

Parameters

value double?

Returns

int?

Sign(short?)

[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(short? value)

Parameters

value short?

Returns

int?

Sign(int?)

[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(int? value)

Parameters

value int?

Returns

int?

Sign(long?)

[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(long? value)

Parameters

value long?

Returns

int?

Sign(sbyte?)

[CLSCompliant(false)]
[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(sbyte? value)

Parameters

value sbyte?

Returns

int?

Sign(float?)

[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(float? value)

Parameters

value float?

Returns

int?

Sin(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Sin(double? value)

Parameters

value double?

Returns

double?

Sinh(double?)

[Sql.Function("ClickHouse", "sinh", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Sinh(double? value)

Parameters

value double?

Returns

double?

Space(int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SapHana", "Lpad('',{0},' ')", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "leftPadUTF8('', toUInt32({0}), ' ')", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Space(int? length)

Parameters

length int?

Returns

string

Sqrt(double?)

[Sql.Function("Access", "Sqr", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Sqrt(double? value)

Parameters

value double?

Returns

double?

StringAggregate(IEnumerable<string?>, string)

[Sql.Extension("SqlServer.2022", "STRING_AGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2019", "STRING_AGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2017", "STRING_AGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("PostgreSQL", "STRING_AGG({source}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("SapHana", "STRING_AGG({source}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSapHanaBuilder))]
[Sql.Extension("SQLite", "GROUP_CONCAT({source}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("MySql", "GROUP_CONCAT({source}{_}{order_by_clause?} SEPARATOR {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle", "LISTAGG({source}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle.Native", "LISTAGG({source}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2", "LISTAGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.LUW", "LISTAGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.z/OS", "LISTAGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Firebird", "LIST({source}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("ClickHouse", "arrayStringConcat(groupArray({source}), {separator})", IsAggregate = true, ChainPrecedence = 10, CanBeNull = false)]
public static Sql.IAggregateFunctionNotOrdered<string?, string> StringAggregate(this IEnumerable<string?> source, string separator)

Parameters

source IEnumerable<string>
separator string

Returns

Sql.IAggregateFunctionNotOrdered<string, string>

StringAggregate(IQueryable<string?>, string)

[Sql.Extension("SqlServer.2022", "STRING_AGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2019", "STRING_AGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2017", "STRING_AGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("PostgreSQL", "STRING_AGG({source}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("SapHana", "STRING_AGG({source}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSapHanaBuilder))]
[Sql.Extension("SQLite", "GROUP_CONCAT({source}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("MySql", "GROUP_CONCAT({source}{_}{order_by_clause?} SEPARATOR {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle", "LISTAGG({source}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle.Native", "LISTAGG({source}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2", "LISTAGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.LUW", "LISTAGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.z/OS", "LISTAGG({source}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Firebird", "LIST({source}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("ClickHouse", "arrayStringConcat(groupArray({source}), {separator})", IsAggregate = true, ChainPrecedence = 10, CanBeNull = false)]
public static Sql.IAggregateFunctionNotOrdered<string?, string> StringAggregate(this IQueryable<string?> source, string separator)

Parameters

source IQueryable<string>
separator string

Returns

Sql.IAggregateFunctionNotOrdered<string, string>

StringAggregate<T>(IEnumerable<T>, string, Func<T, string?>)

[Sql.Extension("SqlServer.2022", "STRING_AGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2019", "STRING_AGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2017", "STRING_AGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("PostgreSQL", "STRING_AGG({selector}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("SapHana", "STRING_AGG({selector}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSapHanaBuilder))]
[Sql.Extension("SQLite", "GROUP_CONCAT({selector}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("MySql", "GROUP_CONCAT({selector}{_}{order_by_clause?} SEPARATOR {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle", "LISTAGG({selector}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle.Native", "LISTAGG({selector}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2", "LISTAGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.LUW", "LISTAGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.z/OS", "LISTAGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Firebird", "LIST({selector}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("ClickHouse", "arrayStringConcat(groupArray({selector}), {separator})", IsAggregate = true, ChainPrecedence = 10, CanBeNull = false)]
public static Sql.IAggregateFunctionNotOrdered<T, string> StringAggregate<T>(this IEnumerable<T> source, string separator, Func<T, string?> selector)

Parameters

source IEnumerable<T>
separator string
selector Func<T, string>

Returns

Sql.IAggregateFunctionNotOrdered<T, string>

Type Parameters

T

StringAggregate<T>(IQueryable<T>, string, Expression<Func<T, string?>>)

[Sql.Extension("SqlServer.2022", "STRING_AGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2019", "STRING_AGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("SqlServer.2017", "STRING_AGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSql2017Builder))]
[Sql.Extension("PostgreSQL", "STRING_AGG({selector}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("SapHana", "STRING_AGG({selector}, {separator}{_}{order_by_clause?})", IsAggregate = true, ChainPrecedence = 10, BuilderType = typeof(Sql.StringAggSapHanaBuilder))]
[Sql.Extension("SQLite", "GROUP_CONCAT({selector}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("MySql", "GROUP_CONCAT({selector}{_}{order_by_clause?} SEPARATOR {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle", "LISTAGG({selector}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Oracle.Native", "LISTAGG({selector}, {separator}) {aggregation_ordering}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2", "LISTAGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.LUW", "LISTAGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("DB2.z/OS", "LISTAGG({selector}, {separator}){_}{aggregation_ordering?}", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("Firebird", "LIST({selector}, {separator})", IsAggregate = true, ChainPrecedence = 10)]
[Sql.Extension("ClickHouse", "arrayStringConcat(groupArray({selector}), {separator})", IsAggregate = true, ChainPrecedence = 10, CanBeNull = false)]
public static Sql.IAggregateFunctionNotOrdered<T, string> StringAggregate<T>(this IQueryable<T> source, string separator, Expression<Func<T, string?>> selector)

Parameters

source IQueryable<T>
separator string
selector Expression<Func<T, string>>

Returns

Sql.IAggregateFunctionNotOrdered<T, string>

Type Parameters

T

Stuff(IEnumerable<string>, int?, int?, string)

[Sql.Function(ServerSideOnly = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "concat(substringUTF8({0}, 1, {1} - 1), {3}, substringUTF8({0}, {1} + {2}))", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string Stuff(IEnumerable<string> characterExpression, int? start, int? length, string replaceWithExpression)

Parameters

characterExpression IEnumerable<string>
start int?
length int?
replaceWithExpression string

Returns

string

Stuff(string?, int?, int?, string?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "concat(substringUTF8({0}, 1, {1} - 1), {3}, substringUTF8({0}, {1} + {2}))", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Stuff(string? str, int? start, int? length, string? newString)

Parameters

str string
start int?
length int?
newString string

Returns

string

Substring(string?, int?, int?)

[Sql.Function(PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Access", "Mid", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("DB2", "Substr", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Informix", "Substr", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("Oracle", "Substr", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("SQLite", "Substr", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Firebird", "Substring({0} from {1} for {2})", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Substring(string? str, int? start, int? length)

Parameters

str string
start int?
length int?

Returns

string

TableAlias(string)

public static Sql.SqlID TableAlias(string id)

Parameters

id string

Returns

Sql.SqlID

TableExpr(object)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static ISqlExpression TableExpr(object tableExpr)

Parameters

tableExpr object

Returns

ISqlExpression

TableExpr(object, TableQualification)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static ISqlExpression TableExpr(object tableExpr, Sql.TableQualification qualification)

Parameters

tableExpr object
qualification Sql.TableQualification

Returns

ISqlExpression

TableExpr<T>(ITable<T>)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilderDirect))]
public static ISqlExpression TableExpr<T>(ITable<T> table) where T : notnull

Parameters

table ITable<T>

Returns

ISqlExpression

Type Parameters

T

TableExpr<T>(ITable<T>, TableQualification)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilderDirect))]
public static ISqlExpression TableExpr<T>(ITable<T> table, Sql.TableQualification qualification) where T : notnull

Parameters

table ITable<T>
qualification Sql.TableQualification

Returns

ISqlExpression

Type Parameters

T

TableField<TEntity, TColumn>(TEntity, string)

[Sql.Extension("", BuilderType = typeof(Sql.TableFieldBuilder))]
public static TColumn TableField<TEntity, TColumn>(TEntity entity, string fieldName)

Parameters

entity TEntity
fieldName string

Returns

TColumn

Type Parameters

TEntity
TColumn

TableName(object)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static string TableName(object tableExpr)

Parameters

tableExpr object

Returns

string

TableName(object, TableQualification)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static string TableName(object tableExpr, Sql.TableQualification qualification)

Parameters

tableExpr object
qualification Sql.TableQualification

Returns

string

TableName(string)

public static Sql.SqlID TableName(string id)

Parameters

id string

Returns

Sql.SqlID

TableName<T>(ITable<T>)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilderDirect))]
public static string TableName<T>(ITable<T> table) where T : notnull

Parameters

table ITable<T>

Returns

string

Type Parameters

T

TableName<T>(ITable<T>, TableQualification)

[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilderDirect))]
public static string TableName<T>(ITable<T> table, Sql.TableQualification qualification) where T : notnull

Parameters

table ITable<T>
qualification Sql.TableQualification

Returns

string

Type Parameters

T

TableSpec(string)

public static Sql.SqlID TableSpec(string id)

Parameters

id string

Returns

Sql.SqlID

Tan(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Tan(double? value)

Parameters

value double?

Returns

double?

Tanh(double?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Tanh(double? value)

Parameters

value double?

Returns

double?

ToDate(int?, int?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static DateTime? ToDate(int? year, int? month, int? day)

Parameters

year int?
month int?
day int?

Returns

DateTime?

ToDate(int?, int?, int?, int?, int?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static DateTime? ToDate(int? year, int? month, int? day, int? hour, int? minute, int? second)

Parameters

year int?
month int?
day int?
hour int?
minute int?
second int?

Returns

DateTime?

ToDate(int?, int?, int?, int?, int?, int?, int?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static DateTime? ToDate(int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond)

Parameters

year int?
month int?
day int?
hour int?
minute int?
second int?
millisecond int?

Returns

DateTime?

ToNotNull<T>(T?)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T ToNotNull<T>(T? value) where T : struct

Parameters

value T?

Returns

T

Type Parameters

T

ToNotNullable<T>(T?)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T ToNotNullable<T>(T? value) where T : struct

Parameters

value T?

Returns

T

Type Parameters

T

ToNullable<T>(T)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T? ToNullable<T>(T value) where T : struct

Parameters

value T

Returns

T?

Type Parameters

T

ToSql<T>(T)

[CLSCompliant(false)]
[Sql.Expression("{0}", new int[] { 0 }, ServerSideOnly = true, InlineParameters = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T ToSql<T>(T obj)

Parameters

obj T

Returns

T

Type Parameters

T

Trim(string?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Trim(string? str)

Parameters

str string

Returns

string

Trim(string?, char?)

[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("DB2", "Strip({0}, B, {1})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "trim(BOTH {1} FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Trim(string? str, char? ch)

Parameters

str string
ch char?

Returns

string

TrimLeft(string?)

[Sql.Expression("Firebird", "TRIM(LEADING FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("LTrim", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "trimLeft", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? TrimLeft(string? str)

Parameters

str string

Returns

string

TrimLeft(string?, char?)

[Sql.Expression("ClickHouse", "trim(LEADING {1} FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Firebird", "TRIM(LEADING {1} FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("DB2", "Strip({0}, L, {1})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("LTrim", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? TrimLeft(string? str, char? ch)

Parameters

str string
ch char?

Returns

string

TrimRight(string?)

[Sql.Expression("Firebird", "TRIM(TRAILING FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("RTrim", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "trimRight", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? TrimRight(string? str)

Parameters

str string

Returns

string

TrimRight(string?, char?)

[Sql.Expression("ClickHouse", "trim(TRAILING {1} FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Firebird", "TRIM(TRAILING {1} FROM {0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("DB2", "Strip({0}, T, {1})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("RTrim", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? TrimRight(string? str, char? ch)

Parameters

str string
ch char?

Returns

string

Truncate(decimal?)

[Sql.Expression("SqlServer", "Round({0}, 0, 1)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("DB2", "Truncate({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Informix", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Oracle", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Firebird", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("PostgreSQL", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("MySql", "Truncate({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SqlCe", "Round({0}, 0, 1)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SapHana", "Round({0}, 0, ROUND_DOWN)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static decimal? Truncate(decimal? value)

Parameters

value decimal?

Returns

decimal?

Truncate(double?)

[Sql.Expression("SqlServer", "Round({0}, 0, 1)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("DB2", "Truncate({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Informix", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Oracle", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("Firebird", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("PostgreSQL", "Trunc({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("MySql", "Truncate({0}, 0)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SqlCe", "Round({0}, 0, 1)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SapHana", "Round({0}, 0, ROUND_DOWN)", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Truncate(double? value)

Parameters

value double?

Returns

double?

TryConvertOrDefault<TFrom, TTo>(TFrom, TTo?)

Performs value conversion to specified type. If conversion failed, returns value, specified by defaultValue parameter. Supported databases:

  • Oracle 12.2 or newer (not all conversions possible, check Oracle's documentation on CAST expression)
[CLSCompliant(false)]
[Sql.Function("$TryConvertOrDefault$", new int[] { 3, 2, 0, 1 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static TTo? TryConvertOrDefault<TFrom, TTo>(TFrom value, TTo? defaultValue) where TTo : struct

Parameters

value TFrom

Value to convert.

defaultValue TTo?

Value, returned when conversion failed.

Returns

TTo?

Value, converted to target type or defaultValue if conversion failed.

Type Parameters

TFrom

Source value type.

TTo

Target value type.

TryConvertOrDefault<TFrom, TTo>(TFrom, TTo?)

Performs value conversion to specified type. If conversion failed, returns value, specified by defaultValue parameter. Supported databases:

  • Oracle 12.2 or newer (not all conversions possible, check Oracle's documentation on CAST expression)
[CLSCompliant(false)]
[Sql.Function("$TryConvertOrDefault$", new int[] { 3, 2, 0, 1 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static TTo? TryConvertOrDefault<TFrom, TTo>(TFrom value, TTo? defaultValue) where TTo : class

Parameters

value TFrom

Value to convert.

defaultValue TTo

Value, returned when conversion failed.

Returns

TTo

Value, converted to target type or defaultValue if conversion failed.

Type Parameters

TFrom

Source value type.

TTo

Target value type.

TryConvert<TFrom, TTo>(TFrom, TTo?)

Performs value conversion to specified type. If conversion failed, returns null. Supported databases:

  • SQL Server 2012 or newer
  • Oracle 12.2 or newer (not all conversions possible, check Oracle's documentation on CAST expression)
[CLSCompliant(false)]
[Sql.Function("$TryConvert$", new int[] { 3, 2, 0 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.Nullable)]
public static TTo? TryConvert<TFrom, TTo>(TFrom value, TTo? _) where TTo : struct

Parameters

value TFrom

Value to convert.

_ TTo?

Unused. Added to support method overloads.

Returns

TTo?

Value, converted to target type or null if conversion failed.

Type Parameters

TFrom

Source value type.

TTo

Target value type.

TryConvert<TFrom, TTo>(TFrom, TTo?)

Performs value conversion to specified type. If conversion failed, returns null. Supported databases:

  • SQL Server 2012 or newer
  • Oracle 12.2 or newer (not all conversions possible, check Oracle's documentation on CAST expression)
[CLSCompliant(false)]
[Sql.Function("$TryConvert$", new int[] { 3, 2, 0 }, ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.Nullable)]
public static TTo? TryConvert<TFrom, TTo>(TFrom value, TTo? _) where TTo : class

Parameters

value TFrom

Value to convert.

_ TTo

Unused. Added to support method overloads.

Returns

TTo

Value, converted to target type or null if conversion failed.

Type Parameters

TFrom

Source value type.

TTo

Target value type.

Upper(string?)

[Sql.Function("$ToUpper$", ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Upper(string? str)

Parameters

str string

Returns

string

ZeroPad(int?, int)

[Sql.Expression("Lpad({0},{1},'0')", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("Access", "Format({0}, String('0', {1}))", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("Sybase", "right(replicate('0',{1}) + cast({0} as varchar(255)),{1})", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("PostgreSQL", "Lpad({0}::text,{1},'0')", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("SQLite", "printf('%0{1}d', {0})", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("ClickHouse", "leftPadUTF8(toString({0}), toUInt32({1}), '0')", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("SqlCe", "REPLICATE('0', {1} - LEN(CAST({0} as NVARCHAR({1})))) + CAST({0} as NVARCHAR({1}))", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("SqlServer", "format({0}, 'd{1}')", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("SqlServer.2005", "REPLICATE('0', CASE WHEN LEN(CAST({0} as NVARCHAR)) > {1} THEN 0 ELSE ({1} - LEN(CAST({0} as NVARCHAR))) END) + CAST({0} as NVARCHAR)", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
[Sql.Expression("SqlServer.2008", "REPLICATE('0', CASE WHEN LEN(CAST({0} as NVARCHAR)) > {1} THEN 0 ELSE ({1} - LEN(CAST({0} as NVARCHAR))) END) + CAST({0} as NVARCHAR)", IsNullable = Sql.IsNullableType.SameAsFirstParameter)]
public static string? ZeroPad(int? val, int length)

Parameters

val int?
length int

Returns

string