Mapping delle funzioni del provider SQLite EF Core
Questa pagina mostra i membri .NET convertiti in quali funzioni SQL quando si usa il provider SQLite.
Funzioni di aggregazione
.NET | SQL | Aggiunta in |
---|---|---|
gruppo. Average(x => x.Property) | AVG(Property) | |
gruppo. Average(x => x.DecimalProperty) | ef_avg(DecimalProperty) | EF Core 9.0 |
gruppo. Count() | COUNT(*) | |
gruppo. LongCount() | COUNT(*) | |
gruppo. Max(x => x.Property) | MAX(Property) | |
gruppo. Min(x => x.Property) | MIN(Property) | |
gruppo. Sum(x => x.Property) | SUM(Property) | |
gruppo. Sum(x => x.DecimalProperty) | ef_sum(DecimalProperty) | EF Core 9.0 |
corda. Concat(group. Select(x => x.Property)) | group_concat(Property, '') | EF Core 7.0 |
corda. Join(separatore, gruppo. Select(x => x.Property)) | group_concat(Property, @separator) | EF Core 7.0 |
Funzioni binarie
.NET | SQL | Aggiunta in |
---|---|---|
Byte. Contains(value) | instr(@bytes, char(@value)) > 0 | |
Byte. Lunghezza | length(@bytes) | |
Byte. SequenceEqual(second) | @bytes = @second | |
EF. Functions.Hex(byte) | hex(@bytes) | |
EF. Functions.Substr(bytes, startIndex) | substr(@bytes, @startIndex) | |
EF. Functions.Substr(bytes, startIndex, length) | substr(@bytes, @startIndex, @length) | |
EF. Functions.Unhex(value) | unhex(@value) | EF Core 8.0 |
EF. Functions.Unhex(value, ignoreChars) | unhex(@value, @ignoreChars) | EF Core 8.0 |
Funzioni di conversione
.NET | SQL |
---|---|
boolValue.ToString() | CAST(@boolValue AS TEXT) |
byteValue.ToString() | CAST(@byteValue AS TEXT) |
Byte. ToString() | CAST(@bytes AS TEXT) |
charValue.ToString() | CAST(@charValue AS TEXT) |
dateTime.ToString() | CAST(@dateTime AS TEXT) |
dateTimeOffset.ToString() | CAST(@dateTimeOffset AS TEXT) |
decimalValue.ToString() | CAST(@decimalValue AS TEXT) |
doubleValue.ToString() | CAST(@doubleValue AS TEXT) |
floatValue.ToString() | CAST(@floatValue AS TEXT) |
Guid. ToString() | CAST(@guid AS TEXT) |
intValue.ToString() | CAST(@intValue AS TEXT) |
longValue.ToString() | CAST(@longValue AS TEXT) |
sbyteValue.ToString() | CAST(@sbyteValue AS TEXT) |
shortValue.ToString() | CAST(@shortValue AS TEXT) |
timeSpan.ToString() | CAST(@timeSpan AS TEXT) |
uintValue.ToString() | CAST(@uintValue AS TEXT) |
ushortValue.ToString() | CAST(@ushortValue AS TEXT) |
Funzioni di data e ora
.NET | SQL | Aggiunta in |
---|---|---|
dateOnly.AddDays(value) | date(@dateOnly, @value || ' giorni') | |
dateOnly.AddMonths(months) | date(@dateOnly, @months || ' months') | |
dateOnly.AddYears(value) | date(@dateOnly, @value || ' anni') | |
dateOnly.Day | strftime('%d', @dateOnly) | |
dateOnly.DayOfWeek | strftime('%w', @dateOnly) | |
dateOnly.DayOfYear | strftime('%j', @dateOnly) | |
DateOnly.FromDateTime(dateTime) | date(@dateTime) | EF Core 8.0 |
dateOnly.Month | strftime('%m', @dateOnly) | |
dateOnly.Year | strftime('%Y', @dateOnly) | |
DateTime.Now | datetime('now', 'localtime') | |
DateTime.Today | datetime('now', 'localtime', 'start of day') | |
DateTime.UtcNow | datetime('now') | |
dateTime.AddDays(value) | datetime(@dateTime, @value || ' giorni') | |
dateTime.AddHours(value) | datetime(@dateTime, @d || ' ore') | |
dateTime.AddMilliseconds(value) | datetime(@dateTime, (@value / 1000.0) || ' seconds') | |
dateTime.AddMinutes(value) | datetime(@dateTime, @value || ' minutes') | |
dateTime.AddMonths(months) | datetime(@dateTime, @months || ' months') | |
dateTime.AddSeconds(value) | datetime(@dateTime, @value || ' seconds') | |
dateTime.AddTicks(value) | datetime(@dateTime, (@value / 10000000.0) || ' seconds') | |
dateTime.AddYears(value) | datetime(@dateTime, @value || ' anni') | |
dateTime.Date | datetime(@dateTime, 'inizio del giorno') | |
dateTime.Day | strftime('%d', @dateTime) | |
dateTime.DayOfWeek | strftime('%w', @dateTime) | |
dateTime.DayOfYear | strftime('%j', @dateTime) | |
dateTime.Hour | strftime('%H', @dateTime) | |
dateTime.Millisecond | (strftime('%f', @dateTime) * 1000) % 1000 | |
dateTime.Minute | strftime('%M', @dateTime) | |
dateTime.Month | strftime('%m', @dateTime) | |
dateTime.Second | strftime('%S', @dateTime) | |
dateTime.Ticks | (julianday(@dateTime) - julianday('0001-01-01 00:00:00')) * 8640000000000 | |
dateTime.TimeOfDay | time(@dateTime) | |
dateTime.Year | strftime('%Y', @dateTime) |
Nota
Alcuni SQL sono stati semplificati a scopo illustrativo. L'effettivo SQL è più complesso per gestire un intervallo più ampio di valori.
Funzioni numeriche
.NET | SQL | Aggiunta in |
---|---|---|
-decimalValue | ef_negate(@decimalValue) | |
decimalValue - d | ef_add(@decimalValue, ef_negate(@d)) | |
decimalValue * d | ef_multiply(@decimalValue, @d) | |
decimalValue/d | ef_divide(@decimalValue, @d) | |
decimalValue % d | ef_mod(@decimalValue, @d) | |
decimalValue + d | ef_add(@decimalValue, @d) | |
decimalValue < d | ef_compare(@decimalValue, @d)< 0 | |
decimalValue <= d | ef_compare(@decimalValue, @d)<= 0 | |
decimalValue > d | ef_compare(@decimalValue, @d)> 0 | |
decimalValue >= d | ef_compare(@decimalValue, @d)>= 0 | |
doppio. DegreesToRadians(gradi) | radianti (@degrees) | EF Core 8.0 |
doppio. RadiansToDegrees(radianti) | gradi (@dradians) | EF Core 8.0 |
doubleValue % d | mod(@doubleValue, @d) | |
EF.Functions.Random() | abs(random() / 9223372036854780000.0) | |
Math.Abs(valore) | abs(@value) | |
Math.Acos(value) | acos(@value) | EF Core 8.0 |
Math.Acosh(d) | acosh(@d) | EF Core 8.0 |
Math.Asin(d) | asin(@d) | EF Core 8.0 |
Math.Asinh(d) | asinh(@d) | EF Core 8.0 |
Math.Atan(d) | atan(@d) | EF Core 8.0 |
Math.Atan2(y, x) | atan2(@y, @x) | EF Core 8.0 |
Math.Atanh(d) | atanh(@d) | EF Core 8.0 |
Math.Ceiling(d) | ceiling(@d) | EF Core 8.0 |
Math.Cos(d) | cos(@d) | EF Core 8.0 |
Math.Cosh(value) | cosh(@value) | EF Core 8.0 |
Math.Exp(d) | exp(@d) | EF Core 8.0 |
Math.Floor(d) | floor(@d) | EF Core 8.0 |
Math.Log(d) | ln(@d) | EF Core 8.0 |
Math.Log(a, newBase) | log(@newBase, @a) | EF Core 8.0 |
Math.Log2(x) | log2(@x) | EF Core 8.0 |
Math.Log10(d) | log10(@d) | EF Core 8.0 |
Math.Max(val1, val2) | max(@val1, @val2) | |
Math.Min(val1, val2) | min(@val1, @val2) | |
Math.Pow(x, y) | pow(@x, @y) | EF Core 8.0 |
Math.Round(d) | round(@d) | |
Math.Round(d, digits) | round(@d, @digits) | |
Math.Sign(d) | sign(@d) | EF Core 8.0 |
Math.Sin(a) | sin(@a) | EF Core 8.0 |
Math.Sinh(value) | sinh(@value) | EF Core 8.0 |
Math.Sqrt(d) | sqrt(@d) | EF Core 8.0 |
Math.Tan(a) | tan(@a) | EF Core 8.0 |
Math.Tanh(value) | tanh(@value) | EF Core 8.0 |
Math.Truncate(d) | trunc(@d) | EF Core 8.0 |
Suggerimento
Oltre ai metodi elencati qui, vengono tradotte anche le implementazioni generiche di matematica e i metodi MathF corrispondenti. Ad esempio, Math.Sin
, MathF.Sin
double.Sin
, e float.Sin
tutto esegue il mapping alla sin
funzione in SQL.
Suggerimento
Le funzioni SQL con prefisso ef_
vengono create da EF Core.
Funzioni di stringa
.NET | SQL |
---|---|
Char. ToLower(c) | lower(@c) |
Char. ToUpper(c) | upper(@c) |
EF. Functions.Collate(operando, regole di confronto) | @operand COLLAZIONARE @collation |
EF. Functions.Glob(matchExpression, pattern) | @matchExpression Goccia densa @pattern |
EF. Functions.Like(matchExpression, pattern) | @matchExpression COME @pattern |
EF. Functions.Like(matchExpression, pattern, escapeCharacter) | @matchExpression LIKE @pattern ESCAPE @escapeCharacter |
Regex.IsMatch(input, modello) | @input REGEXP @pattern |
corda. Compare(strA, strB) | CASO QUANDO @strA = @strB POI 0 ... FINE |
corda. Concat(str0, str1) | @str0 || @str1 |
corda. IsNullOrEmpty(value) | @value IS NULL OR @value = '' |
corda. IsNullOrWhiteSpace(value) | @value IS NULL OR trim(@value) = '' |
stringValue.CompareTo(strB) | CASO QUANDO @stringValue = @strB POI 0 ... FINE |
stringValue.Contains(valore) | instr(@stringValue, @value)> 0 |
stringValue.EndsWith(valore) | @stringValue LIKE '%' || @value |
stringValue.FirstOrDefault() | substr(@stringValue, 1, 1) |
stringValue.IndexOf(value) | instr(@stringValue, @value) - 1 |
stringValue.LastOrDefault() | substr(@stringValue, length(@stringValue), 1) |
stringValue.Length | length(@stringValue) |
stringValue.Replace(oldValue, newValue) | replace(@stringValue, @oldValue, @newValue) |
stringValue.StartsWith(value) | @stringValue LIKE @value || '%' |
stringValue.Substring(startIndex) | substr(@stringValue, @startIndex + 1) |
stringValue.Substring(startIndex, length) | substr(@stringValue, @startIndex + 1, @length) |
stringValue.ToLower() | lower(@stringValue) |
stringValue.ToUpper() | upper(@stringValue) |
stringValue.Trim() | trim(@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) |
Nota
Alcuni SQL sono stati semplificati a scopo illustrativo. L'effettivo SQL è più complesso per gestire un intervallo più ampio di valori.
Funzioni varie
.NET | SQL |
---|---|
collection.Contains(item) | @item IN @collection |
enumValue.HasFlag(flag) | @enumValue & @flag = @flag |
Nullable. GetValueOrDefault() | coalesce(@nullable, 0) |
Nullable. GetValueOrDefault(defaultValue) | coalesce(@nullable, @defaultValue) |