Table of Contents

Class Sql

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

Fields

Ext

public static readonly Sql.ISqlExtension? Ext

Field Value

Sql.ISqlExtension

GroupBy

public static Sql.IGroupBy GroupBy

Field Value

Sql.IGroupBy

Window

public static readonly Sql.IWindowFunction Window

Field Value

Sql.IWindowFunction

Properties

CurrentTimestamp

public static DateTime CurrentTimestamp { get; }

Property Value

DateTime

CurrentTimestamp2

public static DateTime CurrentTimestamp2 { get; }

Property Value

DateTime

CurrentTimestampUtc

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)]
[Sql.Function("YDB", "CurrentUtcTimestamp", 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

Methods

Abs(decimal?)

public static decimal? Abs(decimal? value)

Parameters

value decimal?

Returns

decimal?

Abs(double?)

public static double? Abs(double? value)

Parameters

value double?

Returns

double?

Abs(short?)

public static short? Abs(short? value)

Parameters

value short?

Returns

short?

Abs(int?)

public static int? Abs(int? value)

Parameters

value int?

Returns

int?

Abs(long?)

public static long? Abs(long? value)

Parameters

value long?

Returns

long?

Abs(sbyte?)

[CLSCompliant(false)]
public static sbyte? Abs(sbyte? value)

Parameters

value sbyte?

Returns

sbyte?

Abs(float?)

public static float? Abs(float? value)

Parameters

value float?

Returns

float?

Acos(double?)

[Sql.Function("YDB", "Math::Acos", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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(typeof(Sql.AliasExprBuilder), 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 generation of SQL even if an expression can be calculated on client.

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

Parameters

obj T

Returns

T

Type Parameters

T

Asin(double?)

[Sql.Function("YDB", "Math::Asin", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Asin(double? value)

Parameters

value double?

Returns

double?

Atan(double?)

[Sql.Function("YDB", "Math::Atan", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("YDB", "Math::Atan2", 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("YDB", "Math::Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("YDB", "Math::Ceil", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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)]
[Sql.Function("SQLite", "INSTR", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("YDB", "Unicode::Find", new int[] { 1, 0 }, 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.Function("YDB", "Unicode::Find", new int[] { 1, 0, 2 }, IsNullable = Sql.IsNullableType.SameAsFirstOrSecondParameter)]
[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)]
[Sql.Function("SQLite", "INSTR", new int[] { 1, 0 }, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("YDB", "Unicode::Find", 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)]
[Sql.Function("YDB", "Unicode::Find", new int[] { 1, 0, 2 }, IsNullable = Sql.IsNullableType.SameAsFirstOrSecondParameter)]
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, IEnumerable<string?>)

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

public static string? ConcatStrings(string separator, IEnumerable<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 IEnumerable<string>

A collection that contains the strings to concatenate.

Returns

string

ConcatStrings(string, params string?[])

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

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

A string that consists of the elements in arguments delimited by the separator string. If arguments has only one element, the separator is not included.

ConcatStringsNullable(string, IEnumerable<string?>)

Concatenates NOT NULL strings, using the specified separator between each member. Returns NULL if all arguments are NULL. Null values are skipped without adding extra separators.

public static string? ConcatStringsNullable(string separator, IEnumerable<string?> arguments)

Parameters

separator string

Separator inserted between consecutive non-null values.

arguments IEnumerable<string>

Sequence of nullable strings to concatenate.

Returns

string

Concatenated string, or null if the sequence contains only null values or is empty.

Remarks

Can be evaluated client-side or translated server-side when used inside an IQueryable.

Constant<T>(T)

Forces LINQ translator to generate constant for expression.

public static T Constant<T>(T expression)

Parameters

expression T

Returns

T

Type Parameters

T

Convert<TTo, TFrom>(TTo, TFrom)

[CLSCompliant(false)]
[Sql.Extension("", BuilderType = typeof(Sql.ConvertBuilder))]
[SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Used to specify generic parameter")]
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_Format$", new int[] { 0, 3, 1, 2 }, ServerSideOnly = true, IsNullable = Sql.IsNullableType.SameAsSecondParameter)]
[SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Used by builder or to specify generic parameter")]
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.Extension("", BuilderType = typeof(Sql.ConvertBuilderSimple))]
public static TTo Convert<TTo, TFrom>(TFrom obj)

Parameters

obj TFrom

Returns

TTo

Type Parameters

TTo
TFrom

Cos(double?)

[Sql.Function("YDB", "Math::Cos", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Cos(double? value)

Parameters

value double?

Returns

double?

Cosh(double?)

[Sql.Function("YDB", "Math::Cosh", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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.Expression("SQLite", "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?)

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?)

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))]
[Sql.Extension("YDB", "", BuilderType = typeof(Sql.DateDiffBuilderYdb))]
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))]
[Sql.Extension("YDB", "", BuilderType = typeof(Sql.DateDiffBuilderYdb))]
public static int? DateDiff(Sql.DateParts part, DateTime? startDate, DateTime? endDate)

Parameters

part Sql.DateParts
startDate DateTime?
endDate DateTime?

Returns

int?

DatePart(DateParts, DateTimeOffset?)

public static int? DatePart(Sql.DateParts part, DateTimeOffset? date)

Parameters

part Sql.DateParts
date DateTimeOffset?

Returns

int?

DatePart(DateParts, DateTime?)

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("YDB", "Math::Exp", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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

Expr<T>(FormattableString)

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

Parameters

sql FormattableString

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 = true)]
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 = true)]
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 = true)]
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 = true)]
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("YDB", "Math::Floor", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("YDB", "Math::Floor", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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()

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.Expression("SQLite", "SUBSTRING({0}, 1, {1})", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "leftUTF8", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("YDB", "Unicode::Substring({0}, 0, {1})", 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.Function("YDB", "Unicode::GetLength", 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?)

public static bool Like(string? matchExpression, string? pattern)

Parameters

matchExpression string
pattern string

Returns

bool

Like(string?, string?, char?)

public static bool Like(string? matchExpression, string? pattern, char? escapeCharacter)

Parameters

matchExpression string
pattern string
escapeCharacter char?

Returns

bool

Log(decimal?)

[Sql.Function("YDB", "Math::Log", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("SQLite", "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("YDB", "Math::Log({1}) / Math::Log({0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 80)]
[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("YDB", "Math::Log", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("SQLite", "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("YDB", "Math::Log({1}) / Math::Log({0})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 80)]
[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("YDB", "Math::Log10", 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?)

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?)

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()

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?)

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)

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?)

public static T? NullIf<T>(T? value, T? compareTo) where T : class

Parameters

value T
compareTo T

Returns

T

Type Parameters

T

Ordinal<T>(T)

Forces LINQ translator to generate column ordinal for expression column (1-base column index in select statement). Currently it is supported only for ORDER BY clause.

Can be used in LINQ query as top level order expression. For example the following two similar queries
query = query
	.OrderBy(x => Sql.Ordinal(x.Field2))
	.ThenBy(x => x.Field2);
query =	from q in query
	orderby Sql.Ordinal(q.Field2), q.Field1
	select q;

Should generate thw following SQL:

SELECT
   t.Field1,
   t.Field2
FROM SomeTable t
ORDER BY 2, t.Field1
public static T Ordinal<T>(T expression)

Parameters

expression T

Returns

T

The same expression when calling directly.

Type Parameters

T

Exceptions

LinqToDBException

Exception is throw when used not in OrderBy/ThenBy extension methods.

Overlaps<T1>(SqlRow<T1>, SqlRow<T1>)

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

Parameters

thisRow Sql.SqlRow<T1>
other Sql.SqlRow<T1>

Returns

bool

Type Parameters

T1

Overlaps<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)

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

Parameters

thisRow Sql.SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
other Sql.SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>

Returns

bool

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8
T9
T10

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

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

Parameters

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

Returns

bool

Type Parameters

T1
T2

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

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

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3

Overlaps<T1, T2, T3, T4>(SqlRow<T1, T2, T3, T4>, SqlRow<T1, T2, 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, T3, T4> thisRow, Sql.SqlRow<T1, T2, T3, T4> other)

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3
T4

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

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

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3
T4
T5

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

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

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3
T4
T5
T6

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

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

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3
T4
T5
T6
T7

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

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

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

Overlaps<T1, T2, T3, T4, T5, T6, T7, T8, T9>(SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9>, SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9>)

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

Parameters

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

Returns

bool

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8
T9

PadLeft(string?, int?, char?)

[Sql.Function(Name = "LPad", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("ClickHouse", "leftPadUTF8({0}, toUInt32({1}), {2})", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("YDB", "String::LeftPad", 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)]
[Sql.Function("YDB", "String::RightPad", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? PadRight(string? str, int? length, char? paddingChar)

Parameters

str string
length int?
paddingChar char?

Returns

string

Parameter<T>(T)

Forces LINQ translator to generate parameter for expression.

public static T Parameter<T>(T expression)

Parameters

expression T

Returns

T

Type Parameters

T

Power(decimal?, decimal?)

public static decimal? Power(decimal? x, decimal? y)

Parameters

x decimal?
y decimal?

Returns

decimal?

Power(double?, double?)

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

ServerSideOnlyException

'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)]
[Sql.Function("YDB", "Unicode::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?)

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)]
[Sql.Function("YDB", "Unicode::Reverse", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Reverse(string? str)

Parameters

str string

Returns

string

Right(string?, int?)

[Sql.Function("RIGHT", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("SQLite", "SUBSTRING({0}, LENGTH({0}) - {1} + 1)", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function("ClickHouse", "rightUTF8", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Extension("Oracle", "", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable, BuilderType = typeof(Sql.OracleRightBuilder))]
[Sql.Extension("SqlCe", "", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable, BuilderType = typeof(Sql.SqlCeRightBuilder))]
[Sql.Expression("YDB", "Unicode::Substring({0}, CAST(Unicode::GetLength({0}) - {1} AS UInt32), {1})", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Right(string? str, int? length)

Parameters

str string
length int?

Returns

string

Round(decimal?)

public static decimal? Round(decimal? value)

Parameters

value decimal?

Returns

decimal?

Round(decimal?, int?)

public static decimal? Round(decimal? value, int? precision)

Parameters

value decimal?
precision int?

Returns

decimal?

Round(double?)

public static double? Round(double? value)

Parameters

value double?

Returns

double?

Round(double?, int?)

public static double? Round(double? value, int? precision)

Parameters

value double?
precision int?

Returns

double?

RoundToEven(decimal?)

public static decimal? RoundToEven(decimal? value)

Parameters

value decimal?

Returns

decimal?

RoundToEven(decimal?, int?)

public static decimal? RoundToEven(decimal? value, int? precision)

Parameters

value decimal?
precision int?

Returns

decimal?

RoundToEven(double?)

public static double? RoundToEven(double? value)

Parameters

value double?

Returns

double?

RoundToEven(double?, int?)

public static double? RoundToEven(double? value, int? precision)

Parameters

value double?
precision int?

Returns

double?

Row<T1>(T1)

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

Parameters

value1 T1

Returns

Sql.SqlRow<T1>

Type Parameters

T1

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

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

Parameters

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

Returns

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

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8
T9
T10

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, T2, T3> Row<T1, T2, T3>(T1 value1, T2 value2, T3 value3)

Parameters

value1 T1
value2 T2
value3 T3

Returns

Sql.SqlRow<T1, 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, T2, 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, T2, 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, T2, T3, 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, T2, T3, 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, T2, T3, T4, 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, T2, T3, T4, 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, T2, T3, T4, T5, 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, T2, T3, T4, T5, 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, T2, T3, T4, T5, T6, 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, T2, T3, T4, T5, T6, T7, T8>

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8

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

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

Parameters

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

Returns

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

Type Parameters

T1
T2
T3
T4
T5
T6
T7
T8
T9

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("YDB", "Math::Sin", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("YDB", "Math::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)]
[Sql.Expression("SQLite", "REPLACE(HEX(ZEROBLOB({0})), '00', ' ')", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Expression("YDB", "String::LeftPad('', {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("YDB", "Math::Sqrt", 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)

Server-side aggregate placeholder for concatenation of nullable strings. This overload cannot execute on an IEnumerable<T> and will always throw. Use only inside an IQueryable expression tree.

public static Sql.IAggregateFunctionNotOrdered<string?, string> StringAggregate(this IEnumerable<string?> source, string separator)

Parameters

source IEnumerable<string>

Sequence (must be part of query translation). Cannot be null.

separator string

Separator string. Cannot be null.

Returns

Sql.IAggregateFunctionNotOrdered<string, string>

Remarks

LEGACY. Use string.Join(separator, source.Where(s => s != null)) or Sql.ConcatStrings(separator, source) (both forms support client or server execution).

StringAggregate(IQueryable<string?>, string)

Creates a server-side aggregate function that concatenates the elements of a sequence of nullable strings within an IQueryable query, using the specified separator between each element.

public static Sql.IAggregateFunctionNotOrdered<string?, string> StringAggregate(this IQueryable<string?> source, string separator)

Parameters

source IQueryable<string>

Queryable sequence of nullable strings. Cannot be null.

separator string

Separator string. Cannot be null.

Returns

Sql.IAggregateFunctionNotOrdered<string, string>

An Sql.IAggregateFunctionNotOrdered<T, TR> expression representing the aggregation in the query. The database produces the final concatenated string.

Remarks

LEGACY: Retained for backward compatibility. Prefer using one of the following (both forms can execute client-side or be translated when used inside an IQueryable):

string.Join(separator, source.Where(s => s != null))

Sql.ConcatStrings(separator, source)

Exceptions

ArgumentNullException

Thrown if source or separator is null.

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

Server-side aggregate placeholder for concatenation of projected nullable strings. This overload cannot execute on an IEnumerable<T> and will always throw. Use only inside an IQueryable expression tree.

public static Sql.IAggregateFunctionNotOrdered<T, string> StringAggregate<T>(this IEnumerable<T> source, string separator, Func<T, string?> selector)

Parameters

source IEnumerable<T>

Sequence (must be part of query translation). Cannot be null.

separator string

Separator string. Cannot be null.

selector Func<T, string>

Projection producing nullable string values.

Returns

Sql.IAggregateFunctionNotOrdered<T, string>

Type Parameters

T

Remarks

LEGACY. Use string.Join(separator, source.Select(selector).Where(s => s != null)) or Sql.ConcatStrings(separator, source.Select(selector)) (both client/server capable).

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

Creates a server-side aggregate that concatenates projected nullable string values from a queryable sequence, using the specified separator.

public static Sql.IAggregateFunctionNotOrdered<T, string> StringAggregate<T>(this IQueryable<T> source, string separator, Expression<Func<T, string?>> selector)

Parameters

source IQueryable<T>

Queryable source sequence. Cannot be null.

separator string

Separator string. Cannot be null.

selector Expression<Func<T, string>>

Projection producing nullable string values. Cannot be null.

Returns

Sql.IAggregateFunctionNotOrdered<T, string>

Type Parameters

T

Remarks

LEGACY: Retained for backward compatibility. Prefer using one of the following (both can run client-side or be translated when part of an IQueryable):

string.Join(separator, source.Select(selector).Where(s => s != null))

Sql.ConcatStrings(separator, source.Select(selector))

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)]
[Sql.Expression("YDB", "Unicode::Substring({0}, 0, {1} - 1) || {3} || Unicode::Substring({0}, {1} + {2} - 1)", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 5)]
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)]
[Sql.Expression("YDB", "Unicode::Substring({0}, 0, {1} - 1) || {3} || Unicode::Substring({0}, {1} + {2} - 1)", PreferServerSide = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable, Precedence = 5)]
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.Function("YDB", "Unicode::Substring", 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)

[ExpressionMethod("TableFieldIml")]
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("YDB", "Math::Tan", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Tan(double? value)

Parameters

value double?

Returns

double?

Tanh(double?)

[Sql.Function("YDB", "Math::Tanh", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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)

Enforces generation of SQL even if an expression can be calculated on client. All values will be embedded as literals instead of parameters when possible.

[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("YDB", "Unicode::Strip", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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.Function("YDB", "Math::Trunc", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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.Function("YDB", "Math::Trunc", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[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("YDB", "String::LeftPad(CAST({0} as Utf8), {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