Partilhar via


Mapeamentos de função do provedor SQLite EF Core

Esta página mostra quais membros do .NET são convertidos em quais funções SQL ao usar o provedor SQLite.

Funções agregadas

.NET SQL Adicionado em
grupo.média(x => x.Propriedade) AVG(Propriedade)
grupo.Média(x => x.DecimalProperty) ef_avg(DecimalProperty) EF Núcleo 9.0
grupo. Contagem() CONTAGEM(*)
grupo.ContagemLonga() CONTAGEM(*)
grupo.Max(x => x.Propriedade) MAX(Propriedade)
grupo.Min(x => x.Propriedade) MIN (Propriedade)
grupo.Soma(x => x.Propriedade) SOMA(Propriedade)
grupo.Soma(x => x.PropriedadeDecimal) ef_sum(DecimalProperty) EF Núcleo 9.0
string.Concat(grupo.Select(x => x.Property)) group_concat(Propriedade, '')
string.Join(separador, grupo.Select(x =>> x.Property)) group_concat(Propriedade, @separator)

Funções binárias

.NET SQL Adicionado em
bytes. Contém(valor) instr(@bytes, char(@value)) > 0
bytes. Comprimento comprimento(@bytes)
bytes.SequenceEqual(segundo) @bytes = @second
EF.Functions.Hex(bytes) hex(@bytes)
EF. Functions.Substr(bytes, startIndex) substr(@bytes, @startIndex)
EF. Functions.Substr(bytes, startIndex, comprimento) substr(@bytes, @startIndex, @length)
EF.Funções.Unhex(valor) UNHEX(@value)
EF. Functions.Unhex(value, ignoreChars) unhex(@value, @ignoreChars)

Funções de conversão

.NET SQL
boolValue.ToString() CAST(@boolValue COMO TEXTO)
byteValue.ToString() CAST(@byteValue COMO TEXTO)
bytes.ToString() CAST(@bytes COMO TEXTO)
charValue.ToString() CAST(@charValue COMO TEXTO)
dateTime.ToString() CAST(@dateTime COMO TEXTO)
dateTimeOffset.ToString() CAST(@dateTimeOffset COMO TEXTO)
decimalValue.ToString() CAST(@decimalValue COMO TEXTO)
doubleValue.ToString() CAST(@doubleValue COMO TEXTO)
floatValue.ToString() CAST(@floatValue COMO TEXTO)
guid.ToString() CAST(@guid COMO TEXTO)
intValue.ToString() CAST(@intValue COMO TEXTO)
longValue.ToString() CAST(@longValue COMO TEXTO)
sbyteValue.ToString() CAST(@sbyteValue COMO TEXTO)
shortValue.ToString() CAST(@shortValue COMO TEXTO)
timeSpan.ToString() CAST(@timeSpan COMO TEXTO)
uintValue.ToString() CAST(@uintValue COMO TEXTO)
ushortValue.ToString() CAST(@ushortValue COMO TEXTO)

Funções de data e hora

.NET SQL Adicionado em
dateOnly.AddDays(valor) date(@dateOnly, @value || " dias")
dateOnly.AddMonths(meses) Data(@dateOnly, @months || « meses »)
dateOnly.AddYears(valor) Data(@dateOnly, @value || «anos»)
dateOnly.Day strftime('%d', @dateOnly)
dateOnly.DayOfWeek strftime('%w', @dateOnly)
dataApenas.DiaDoAno strftime('%j', @dateOnly)
DateOnly.FromDateTime(dateTime) data(@dateTime)
dateOnly.Mês strftime('%m', @dateOnly)
dateOnly.Ano strftime('%Y', @dateOnly)
dateOnly.DayNumber CAST(julianday(@dateOnly) - julianday('0001-01-01') COMO INTEIRO) EF Núcleo 10.0
DateTime.Now datetime('agora', 'localtime')
DateTime.Today datetime('agora', 'localtime', 'início do dia')
DateTime.UtcNow datetime('now')
dateTime.AddDays(valor) datetime(@dateTime, @value || « dias »)
dateTime.AddHours(valor) datetime(@dateTime, @d || ' horas')
dateTime.AddMilliseconds(valor) datetime(@dateTime, (@value / 1000.0) || ' segundos')
dateTime.AddMinutes(valor) datetime(@dateTime, @value || « minutos »)
dateTime.AddMonths(meses) datetime(@dateTime, @months || « meses »)
dateTime.AddSeconds(valor) datetime(@dateTime, @value || ' segundos')
dateTime.AddTicks(valor) datetime(@dateTime, (@value / 10000000.0) || ' segundos')
dateTime.AddYears(valor) datetime(@dateTime, @value || «anos»)
dateTime.Date datetime(@dateTime, 'início do dia')
dateTime.Day strftime('%d', @dateTime)
dateTime.DayOfWeek strftime('%w', @dateTime)
dateTime.DayOfYear strftime('%j', @dateTime)
dateTime.Hora strftime('%H', @dateTime)
dateTime.Millisecond (strftime('%f', @dateTime) * 1000) % 1000
dateTime.Minute strftime('%M', @dateTime)
dateTime.Mês strftime('%m', @dateTime)
dateTime.Second strftime('%S', @dateTime)
dateTime.Ticks (Julianday(@dateTime) - Julianday('0001-01-01 00:00:00')) * 8640000000000
dateTime.TimeOfDay tempo(@dateTime)
dateTime.Ano strftime('%Y', @dateTime)

Observação

Alguns SQL foram simplificados para fins de ilustração. O SQL real é mais complexo para lidar com uma gama mais ampla de valores.

Funções numéricas

.NET SQL Adicionado em
-decimalValor ef_negate(@decimalValue)
decimalValue - d ef_add(@decimalValue, ef_negate(@d))
decimalValor * d ef_multiply(@decimalValue, @d)
decimalValue / d ef_divide(@decimalValue, @d)
valorDecimal % d ef_mod(@decimalValue, @d)
decimalValue + d ef_add(@decimalValue, @d)
decimalValor < d ef_compare(@decimalValue, @d)< 0
decimalValue <= d ef_compare(@decimalValue, @d)<= 0
decimalValor > d ef_compare(@decimalValue, @d)> 0
decimalValue >= d ef_compare(@decimalValue, @d)>= 0
double.DegreesToRadians(graus) radianos(@degrees)
double.RadiansToDegrees(radianos) graus(@dradians)
doubleValue % d mod(@doubleValue, @d)
EF.Functions.Random() abs(aleatório() / 9223372036854780000.0)
Math.Abs(valor) abs(@value)
Math.Acos(valor) acos(@value)
Math.Acosh(d) ACOSH(@d)
Math.Asin(d) asin(@d)
Math.Asinh(d) Asinh(@d)
Math.Atan(d) Atan(@d)
Math.Atan2(y, x) Atan2(@y, @x)
Math.Atanh(d) Atanh(@d)
Matemática.Teto(d) teto(@d)
Math.Cos(d) cos(@d)
Math.Cosh(valor) Cosh(@value)
Math.Exp(d) exp(@d)
Math.Floor(d) piso(@d)
Math.Log(d) LN(@d) EF Núcleo 8.0
Math.Log(a, newBase) log(@newBase, @a) EF Núcleo 8.0
Math.Log2(x) log2(@x) EF Núcleo 8.0
Math.Log10(d) log10(@d) EF Núcleo 8.0
Math.Max(val1, val2) máx(@val1, @val2)
Math.Min(val1, val2) min(@val1, @val2)
Math.Pow(x, y) POW(@x, @y) EF Núcleo 8.0
Math.Round(d) arredondar(@d)
Math.Round(d, dígitos) redondo(@d, @digits)
Math.Sign(d) sinal(@d) EF Núcleo 8.0
Math.Sin(a) sen(@a) EF Núcleo 8.0
Math.Sinh(valor) Sinh(@value) EF Núcleo 8.0
Math.Sqrt(d) Sqrt(@d) EF Núcleo 8.0
Math.Tan(a) tan(@a) EF Núcleo 8.0
Math.Tanh(valor) Tanh(@value) EF Núcleo 8.0
Math.Truncate(d) trunc(@d) EF Núcleo 8.0

Sugestão

Além dos métodos listados aqui, implementações e métodos matemáticos genéricosMathF correspondentes também são traduzidos. Por exemplo, Math.Sin, MathF.Sin, double.Sine float.Sin todos mapeiam para a função sin no SQL.

Sugestão

As funções SQL prefixadas com ef_ são criadas pelo EF Core.

Funções de cadeia de caracteres

.NET SQL
char.ToLower(c) inferior(@c)
char.ToUpper(c) maiúscula(@c)
EF. Functions.Collate(operando, agrupamento) @operand COLISÃO @collation
EF.Functions.Glob(matchExpression, padrão) @matchExpression GLOB @pattern
EF.Functions.Like(matchExpression, padrão) @matchExpression GOSTO @pattern
EF. Functions.Like(matchExpression, pattern, escapeCharacter) @matchExpression COMO @pattern ESCAPE @escapeCharacter
Regex.IsMatch(entrada, padrão) @input REGEXP @pattern
string.Comparar(strA, strB) CASO SE @strA = @strB ENTÃO 0 ... FIM
string. Concat(str0, str1) @str0 || @str1
string.IsNullOrEmpty(valor) @value É NULO OU @value = ''
string.IsNullOrWhiteSpace(valor) @value É NULO OU trim(@value) = ''
stringValue.CompareTo(strB) CASO SE @stringValue = @strB ENTÃO 0 ... FIM
stringValue.Contains(value) instr(@stringValue, @value)> 0
stringValue.EndsWith(valor) @stringValue GOSTO DE '%' || @value
stringValue.FirstOrDefault() substr(@stringValue, 1, 1)
stringValue.IndexOf(value) instr(@stringValue, @value) - 1
stringValue.LastOrDefault() substr(@stringValue, comprimento(@stringValue), 1)
stringValue.Length comprimento(@stringValue)
stringValue.Replace(oldValue, newValue) substituir(@stringValue, @oldValue, @newValue)
stringValue.StartsWith(valor) @stringValue GOSTO @value || '%'
stringValue.Substring(startIndex) substr(@stringValue, @startIndex + 1)
stringValue.Substring(startIndex, comprimento) substr(@stringValue, @startIndex + 1, @length)
stringValue.ToLower() inferior(@stringValue)
stringValue.ToUpper() superior(@stringValue)
stringValue.Trim() guarnição(@stringValue)
stringValue.Trim(trimChar) trim(@stringValue, @trimChar)
stringValue.TrimEnd() Rtrim(@stringValue)
stringValue.TrimEnd(trimChar) rtrim(@stringValue, @trimChar)
stringValue.TrimStart() Ltrim(@stringValue)
stringValue.TrimStart(trimChar) ltrim(@stringValue, @trimChar)

Observação

Alguns SQL foram simplificados para fins de ilustração. O SQL real é mais complexo para lidar com uma gama mais ampla de valores.

Funções diversas

.NET SQL
coleção.Contains(item) @item EM @collection
enumValue.HasFlag(indicador) @enumValue & @flag = @flag
nullable.GetValueOrDefault() coalesce(@nullable, 0)
nulo.GetValueOrDefault(defaultValue) coalesce(@nullable, @defaultValue)

Ver também