Class Sql
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
public static class Sql
- Inheritance
-
objectSql
Fields
Ext
public static readonly Sql.ISqlExtension? Ext
Field Value
GroupBy
public static Sql.IGroupBy GroupBy
Field Value
Window
public static readonly Sql.IWindowFunction Window
Field Value
Properties
CurrentTimestamp
public static DateTime CurrentTimestamp { get; }
Property Value
CurrentTimestamp2
public static DateTime CurrentTimestamp2 { get; }
Property Value
CurrentTimestampUtc
public static DateTime CurrentTimestampUtc { get; }
Property Value
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
DateFirst
[Sql.Property("@@DATEFIRST", CanBeNull = false)]
[Sql.Property("ClickHouse", "1", CanBeNull = false)]
public static int DateFirst { get; }
Property Value
Methods
Abs(decimal?)
public static decimal? Abs(decimal? value)
Parameters
valuedecimal?
Returns
Abs(double?)
public static double? Abs(double? value)
Parameters
valuedouble?
Returns
Abs(short?)
public static short? Abs(short? value)
Parameters
valueshort?
Returns
Abs(int?)
public static int? Abs(int? value)
Parameters
valueint?
Returns
- int?
Abs(long?)
public static long? Abs(long? value)
Parameters
valuelong?
Returns
- long?
Abs(sbyte?)
[CLSCompliant(false)]
public static sbyte? Abs(sbyte? value)
Parameters
valuesbyte?
Returns
Abs(float?)
public static float? Abs(float? value)
Parameters
valuefloat?
Returns
Acos(double?)
[Sql.Function("YDB", "Math::Acos", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Acos(double? value)
Parameters
valuedouble?
Returns
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
valueT
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
valueT
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
valueT
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
objT
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
valuedouble?
Returns
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
valuedouble?
Returns
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
Returns
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
valueT?lowT?highT?
Returns
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
valueTlowThighT
Returns
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
valuedecimal?
Returns
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
valuedouble?
Returns
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
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
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
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
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
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
argsobject[]
Returns
Concat(params string?[])
public static string? Concat(params string?[] args)
Parameters
argsstring[]
Returns
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
separatorstringThe string to use as a separator.
separatoris included in the returned string only ifargumentshas more than one element.argumentsIEnumerable<string>A collection that contains the strings to concatenate.
Returns
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
separatorstringThe string to use as a separator.
separatoris included in the returned string only ifargumentshas more than one element.argumentsstring[]A collection that contains the strings to concatenate.
Returns
- string
A string that consists of the elements in
argumentsdelimited by theseparatorstring. Ifargumentshas 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
separatorstringSeparator inserted between consecutive non-null values.
argumentsIEnumerable<string>Sequence of nullable strings to concatenate.
Returns
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
expressionT
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
toTTofromTFrom
Returns
- TTo
Type Parameters
TToTFrom
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
toTTofromTFromformatint
Returns
- TTo
Type Parameters
TToTFrom
Convert<TTo, TFrom>(TFrom)
[CLSCompliant(false)]
[Sql.Extension("", BuilderType = typeof(Sql.ConvertBuilderSimple))]
public static TTo Convert<TTo, TFrom>(TFrom obj)
Parameters
objTFrom
Returns
- TTo
Type Parameters
TToTFrom
Cos(double?)
[Sql.Function("YDB", "Math::Cos", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Cos(double? value)
Parameters
valuedouble?
Returns
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
valuedouble?
Returns
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
valuedouble?
Returns
DateAdd(DateParts, double?, DateTimeOffset?)
public static DateTimeOffset? DateAdd(Sql.DateParts part, double? number, DateTimeOffset? date)
Parameters
partSql.DatePartsnumberdouble?dateDateTimeOffset?
Returns
DateAdd(DateParts, double?, DateTime?)
public static DateTime? DateAdd(Sql.DateParts part, double? number, DateTime? date)
Parameters
Returns
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
partSql.DatePartsstartDateDateTimeOffset?endDateDateTimeOffset?
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
Returns
- int?
DatePart(DateParts, DateTimeOffset?)
public static int? DatePart(Sql.DateParts part, DateTimeOffset? date)
Parameters
partSql.DatePartsdateDateTimeOffset?
Returns
- int?
DatePart(DateParts, DateTime?)
public static int? DatePart(Sql.DateParts part, DateTime? date)
Parameters
Returns
- int?
DateToTime(DateTime?)
[Sql.Expression("{0}", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static TimeSpan? DateToTime(DateTime? date)
Parameters
dateDateTime?
Returns
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
valuedecimal?
Returns
Degrees(double?)
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Degrees(double? value)
Parameters
valuedouble?
Returns
Degrees(short?)
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static short? Degrees(short? value)
Parameters
valueshort?
Returns
Degrees(int?)
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Degrees(int? value)
Parameters
valueint?
Returns
- int?
Degrees(long?)
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static long? Degrees(long? value)
Parameters
valuelong?
Returns
- long?
Degrees(sbyte?)
[CLSCompliant(false)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static sbyte? Degrees(sbyte? value)
Parameters
valuesbyte?
Returns
Degrees(float?)
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static float? Degrees(float? value)
Parameters
valuefloat?
Returns
Exp(double?)
[Sql.Function("YDB", "Math::Exp", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Exp(double? value)
Parameters
valuedouble?
Returns
Expr<T>(RawSqlString, params object[])
[Sql.Extension("", BuilderType = typeof(Sql.ExprBuilder), ServerSideOnly = true)]
public static T Expr<T>(RawSqlString sql, params object[] parameters)
Parameters
sqlRawSqlStringparametersobject[]
Returns
- T
Type Parameters
T
Expr<T>(FormattableString)
[Sql.Extension("", BuilderType = typeof(Sql.ExprBuilder), ServerSideOnly = true)]
public static T Expr<T>(FormattableString sql)
Parameters
Returns
- T
Type Parameters
T
FieldExpr(object)
[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static ISqlExpression FieldExpr(object fieldExpr)
Parameters
fieldExprobject
Returns
FieldExpr(object, bool)
[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static ISqlExpression FieldExpr(object fieldExpr, bool qualified)
Parameters
fieldExprobjectqualifiedbool
Returns
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
tableITable<T>fieldExprExpression<Func<T, TV>>
Returns
Type Parameters
TTV
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
tableITable<T>fieldExprExpression<Func<T, TV>>qualifiedbool
Returns
Type Parameters
TTV
FieldName(object)
[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static string FieldName(object fieldExpr)
Parameters
fieldExprobject
Returns
FieldName(object, bool)
[Sql.Extension("", BuilderType = typeof(Sql.FieldNameBuilder), ServerSideOnly = true)]
public static string FieldName(object fieldExpr, bool qualified)
Parameters
fieldExprobjectqualifiedbool
Returns
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
tableITable<T>fieldExprExpression<Func<T, object>>
Returns
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
tableITable<T>fieldExprExpression<Func<T, object>>qualifiedbool
Returns
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
valuedecimal?
Returns
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
valuedouble?
Returns
GetDate()
public static DateTime GetDate()
Returns
Grouping(params object[])
[Sql.Extension("GROUPING({fields, ', '})", ServerSideOnly = true, CanBeNull = false, IsAggregate = true)]
public static int Grouping(params object[] fields)
Parameters
fieldsobject[]
Returns
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
valueTotherT?
Returns
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
valueTotherT
Returns
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
valueTotherT?
Returns
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
valueTotherT
Returns
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
Returns
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
valuebyte[]
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
valueBinary
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
strstring
Returns
- int?
Like(string?, string?)
public static bool Like(string? matchExpression, string? pattern)
Parameters
Returns
Like(string?, string?, char?)
public static bool Like(string? matchExpression, string? pattern, char? escapeCharacter)
Parameters
Returns
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
valuedecimal?
Returns
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
Returns
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
valuedouble?
Returns
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
Returns
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
valuedouble?
Returns
Lower(string?)
[Sql.Function("$ToLower$", ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Lower(string? str)
Parameters
strstring
Returns
MakeDateTime(int?, int?, int?)
public static DateTime? MakeDateTime(int? year, int? month, int? day)
Parameters
Returns
MakeDateTime(int?, int?, int?, int?, int?, int?)
public static DateTime? MakeDateTime(int? year, int? month, int? day, int? hour, int? minute, int? second)
Parameters
Returns
NewGuid()
public static Guid NewGuid()
Returns
NoConvert<T>(T)
[Sql.Extension("", BuilderType = typeof(Sql.NoConvertBuilder), ServerSideOnly = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static T NoConvert<T>(T expr)
Parameters
exprT
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
valueT?lowT?highT?
Returns
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
valueTlowThighT
Returns
Type Parameters
T
NullIf<T>(T?, T?)
public static T? NullIf<T>(T? value, T? compareTo) where T : struct
Parameters
valueT?compareToT?
Returns
- T?
Type Parameters
T
NullIf<T>(T?, T)
public static T? NullIf<T>(T? value, T compareTo) where T : struct
Parameters
valueT?compareToT
Returns
- T?
Type Parameters
T
NullIf<T>(T?, T?)
public static T? NullIf<T>(T? value, T? compareTo) where T : class
Parameters
valueTcompareToT
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.
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
expressionT
Returns
- T
The same
expressionwhen 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
Returns
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
thisRowSql.SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>otherSql.SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
Returns
Type Parameters
T1T2T3T4T5T6T7T8T9T10
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
Returns
Type Parameters
T1T2
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
Returns
Type Parameters
T1T2T3
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
Returns
Type Parameters
T1T2T3T4
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
Returns
Type Parameters
T1T2T3T4T5
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
Returns
Type Parameters
T1T2T3T4T5T6
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
Returns
Type Parameters
T1T2T3T4T5T6T7
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
Returns
Type Parameters
T1T2T3T4T5T6T7T8
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
thisRowSql.SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9>otherSql.SqlRow<T1, T2, T3, T4, T5, T6, T7, T8, T9>
Returns
Type Parameters
T1T2T3T4T5T6T7T8T9
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
Returns
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
Returns
Parameter<T>(T)
Forces LINQ translator to generate parameter for expression.
public static T Parameter<T>(T expression)
Parameters
expressionT
Returns
- T
Type Parameters
T
Power(decimal?, decimal?)
public static decimal? Power(decimal? x, decimal? y)
Parameters
Returns
Power(double?, double?)
public static double? Power(double? x, double? y)
Parameters
Returns
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
entityobjectThe entity.
propertyNamestringName of the property.
Returns
- T
Type Parameters
TProperty 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
Returns
Replace(string?, string?, string?)
public static string? Replace(string? str, string? oldValue, string? newValue)
Parameters
Returns
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
strstring
Returns
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
Returns
Round(decimal?)
public static decimal? Round(decimal? value)
Parameters
valuedecimal?
Returns
Round(decimal?, int?)
public static decimal? Round(decimal? value, int? precision)
Parameters
Returns
Round(double?)
public static double? Round(double? value)
Parameters
valuedouble?
Returns
Round(double?, int?)
public static double? Round(double? value, int? precision)
Parameters
Returns
RoundToEven(decimal?)
public static decimal? RoundToEven(decimal? value)
Parameters
valuedecimal?
Returns
RoundToEven(decimal?, int?)
public static decimal? RoundToEven(decimal? value, int? precision)
Parameters
Returns
RoundToEven(double?)
public static double? RoundToEven(double? value)
Parameters
valuedouble?
Returns
RoundToEven(double?, int?)
public static double? RoundToEven(double? value, int? precision)
Parameters
Returns
Row<T1>(T1)
[Sql.Extension("", BuilderType = typeof(Sql.RowBuilder), ServerSideOnly = true)]
public static Sql.SqlRow<T1> Row<T1>(T1 value1)
Parameters
value1T1
Returns
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
value1T1value2T2value3T3value4T4value5T5value6T6value7T7value8T8value9T9value10T10
Returns
Type Parameters
T1T2T3T4T5T6T7T8T9T10
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
value1T1value2T2
Returns
Type Parameters
T1T2
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
value1T1value2T2value3T3
Returns
Type Parameters
T1T2T3
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
value1T1value2T2value3T3value4T4
Returns
Type Parameters
T1T2T3T4
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
value1T1value2T2value3T3value4T4value5T5
Returns
Type Parameters
T1T2T3T4T5
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
value1T1value2T2value3T3value4T4value5T5value6T6
Returns
Type Parameters
T1T2T3T4T5T6
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
value1T1value2T2value3T3value4T4value5T5value6T6value7T7
Returns
Type Parameters
T1T2T3T4T5T6T7
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
value1T1value2T2value3T3value4T4value5T5value6T6value7T7value8T8
Returns
Type Parameters
T1T2T3T4T5T6T7T8
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
value1T1value2T2value3T3value4T4value5T5value6T6value7T7value8T8value9T9
Returns
Type Parameters
T1T2T3T4T5T6T7T8T9
Sign(decimal?)
[Sql.Function("Access", "Sgn", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static int? Sign(decimal? value)
Parameters
valuedecimal?
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
valuedouble?
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
valueshort?
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
valueint?
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
valuelong?
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
valuesbyte?
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
valuefloat?
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
valuedouble?
Returns
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
valuedouble?
Returns
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
lengthint?
Returns
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
valuedouble?
Returns
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
sourceIEnumerable<string>Sequence (must be part of query translation). Cannot be null.
separatorstringSeparator string. Cannot be null.
Returns
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
sourceIQueryable<string>Queryable sequence of nullable strings. Cannot be null.
separatorstringSeparator 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
sourceorseparatoris 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
sourceIEnumerable<T>Sequence (must be part of query translation). Cannot be null.
separatorstringSeparator string. Cannot be null.
selectorFunc<T, string>Projection producing nullable string values.
Returns
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
sourceIQueryable<T>Queryable source sequence. Cannot be null.
separatorstringSeparator string. Cannot be null.
selectorExpression<Func<T, string>>Projection producing nullable string values. Cannot be null.
Returns
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
characterExpressionIEnumerable<string>startint?lengthint?replaceWithExpressionstring
Returns
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
Returns
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
Returns
TableAlias(string)
public static Sql.SqlID TableAlias(string id)
Parameters
idstring
Returns
TableExpr(object)
[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static ISqlExpression TableExpr(object tableExpr)
Parameters
tableExprobject
Returns
TableExpr(object, TableQualification)
[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static ISqlExpression TableExpr(object tableExpr, Sql.TableQualification qualification)
Parameters
tableExprobjectqualificationSql.TableQualification
Returns
TableExpr<T>(ITable<T>)
[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilderDirect))]
public static ISqlExpression TableExpr<T>(ITable<T> table) where T : notnull
Parameters
tableITable<T>
Returns
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
tableITable<T>qualificationSql.TableQualification
Returns
Type Parameters
T
TableField<TEntity, TColumn>(TEntity, string)
[ExpressionMethod("TableFieldIml")]
public static TColumn TableField<TEntity, TColumn>(TEntity entity, string fieldName)
Parameters
entityTEntityfieldNamestring
Returns
- TColumn
Type Parameters
TEntityTColumn
TableName(object)
[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static string TableName(object tableExpr)
Parameters
tableExprobject
Returns
TableName(object, TableQualification)
[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilder), ServerSideOnly = true)]
public static string TableName(object tableExpr, Sql.TableQualification qualification)
Parameters
tableExprobjectqualificationSql.TableQualification
Returns
TableName(string)
public static Sql.SqlID TableName(string id)
Parameters
idstring
Returns
TableName<T>(ITable<T>)
[Sql.Extension("", BuilderType = typeof(Sql.TableNameBuilderDirect))]
public static string TableName<T>(ITable<T> table) where T : notnull
Parameters
tableITable<T>
Returns
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
tableITable<T>qualificationSql.TableQualification
Returns
Type Parameters
T
TableSpec(string)
public static Sql.SqlID TableSpec(string id)
Parameters
idstring
Returns
Tan(double?)
[Sql.Function("YDB", "Math::Tan", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Tan(double? value)
Parameters
valuedouble?
Returns
Tanh(double?)
[Sql.Function("YDB", "Math::Tanh", IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static double? Tanh(double? value)
Parameters
valuedouble?
Returns
ToDate(int?, int?, int?)
[Sql.Function(IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static DateTime? ToDate(int? year, int? month, int? day)
Parameters
Returns
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
Returns
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
Returns
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
valueT?
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
valueT?
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
valueT
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
objT
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
strstring
Returns
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
Returns
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
strstring
Returns
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
Returns
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
strstring
Returns
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
Returns
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
valuedecimal?
Returns
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
valuedouble?
Returns
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
valueTFromValue to convert.
defaultValueTTo?Value, returned when conversion failed.
Returns
- TTo?
Value, converted to target type or
defaultValueif conversion failed.
Type Parameters
TFromSource value type.
TToTarget 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
valueTFromValue to convert.
defaultValueTToValue, returned when conversion failed.
Returns
- TTo
Value, converted to target type or
defaultValueif conversion failed.
Type Parameters
TFromSource value type.
TToTarget 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
valueTFromValue to convert.
_TTo?Unused. Added to support method overloads.
Returns
- TTo?
Value, converted to target type or
nullif conversion failed.
Type Parameters
TFromSource value type.
TToTarget 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
valueTFromValue to convert.
_TToUnused. Added to support method overloads.
Returns
- TTo
Value, converted to target type or
nullif conversion failed.
Type Parameters
TFromSource value type.
TToTarget value type.
Upper(string?)
[Sql.Function("$ToUpper$", ServerSideOnly = true, IsPure = true, IsNullable = Sql.IsNullableType.IfAnyParameterNullable)]
public static string? Upper(string? str)
Parameters
strstring
Returns
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)