Mapování funkcí zprostředkovatele SQLite EF Core

Tato stránka ukazuje, které členy .NET jsou přeloženy do kterých funkcí SQL při použití zprostředkovatele SQLite.

Agregační funkce

Obecné informace o používání agregačních funkcí v dotazech najdete v tématu Agregační funkce.

platforma .NET SQL Přidáno do
skupina.Průměr(x => x.Vlastnost) AVG(Vlastnost)
skupina.Průměr(x => x.DecimalProperty) ef_avg(DecimalProperty) EF Core 9.0
skupina.Count() COUNT(*)
skupina. LongCount() COUNT(*)
skupina.Max(x => x.Property) MAX(Vlastnost)
skupina. Min(x => x.Property) MIN(Atribut)
skupina.Sum(x => x.Property) SUMA(Vlastnost)
skupina.Sum(x => x.DecimalProperty) ef_sum(DecimalProperty) EF Core 9.0
string.Concat(group.Select(x => x.Property)) group_concat(Vlastnost; '')
string.Concat(group.OrderBy(x => x.Other).Select(x => x.Property)) group_concat(vlastnost; '' ORDER BY Other) EF Core 11.0
řetězec.Join(oddělovač, skupina.Select(x => x.Property)) group_concat(vlastnost, @separator)
string.Join(separator, group.OrderBy(x => x.Other).Select(x => x.Property)) group_concat(vlastnost, @separator ORDER BY Other) EF Core 11.0

Binární funkce

platforma .NET SQL Přidáno do
byty. Contains(value) instr(@bytes; char(@value)) > 0
byty. Délka length(@bytes)
bajty.SequenceEqual(druhý) @bytes = @second
EF.Functions.Hex(bajty) hex(@bytes)
EF.Functions.Substr(bytes, startIndex) substr(@bytes, @startIndex)
EF. Functions.Substr(bajty, startIndex, délka) substr(@bytes; @startIndex, @length)
EF.Functions.Unhex(value) unhex(@value) - převede hexadecimální hodnotu na číselnou hodnotu
EF.Functions.Unhex(value, ignoreChars) unhex(@value; @ignoreChars)

Převodní funkce

platforma .NET SQL
boolValue.ToString() CAST(@boolValue AS TEXT)
byteValue.ToString() CAST(@byteValue AS TEXT)
bytes.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)

Funkce pro datum a čas

platforma .NET SQL Přidáno do
dateOnly.AddDays(value) date(@dateOnly, @value || ' dní')
dateOnly.AddMonths(months) (přidá měsíce k datu) date(@dateOnly; @months || "měsíce")
dateOnly.AddYears(value) date(@dateOnly, @value || ' let')
dateOnly.Day strftime('%d', @dateOnly)
dateOnly.DayOfWeek strftime('%w', @dateOnly)
`dateOnly.DenVRoce` strftime('%j', @dateOnly)
DateOnly.FromDateTime(dateTime) date(@dateTime)
dateOnly.Month (měsíc) strftime('%m', @dateOnly)
Rok z dateOnly.Year strftime('%Y', @dateOnly)
dateOnly.DayNumber CAST(julianday(@dateOnly) - julianday('0001-01-01') AS INTEGER) EF Core 10.0
DateTime.Now datetime('now', 'localtime')
DateTime.Today datetime('now', 'localtime', 'začátek dne')
DateTime.UtcNow datetime('now')
dateTime.AddDays(value) datetime(@dateTime, @value || ' dny')
dateTime.AddHours(value) datetime(@dateTime, @d || ' hodin')
dateTime.AddMilliseconds(value) datetime(@dateTime, (@value / 1000.0) || ' sekundy')
dateTime.AddMinutes(hodnota) datetime(@dateTime, @value || ' minuty')
dateTime.AddMonths(months) datetime(@dateTime; @months || "měsíce")
dateTime.AddSeconds(value) datetime(@dateTime, @value || " sekundy")
dateTime.AddTicks(value) datetime(@dateTime, (@value / 10000000.0) || ' sekunda')
dateTime.AddYears(value) datetime(@dateTime, @value || 'rok')
dateTime.Date datetime(@dateTime; "začátek dne")
dateTime.Day strftime('%d', @dateTime)
dateTime.DayOfWeek (den v týdnu) strftime('%w', @dateTime)
dateTime.DayOfYear strftime('%j', @dateTime)
dateTime.Hodina 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 čas(@dateTime)
dateTime.Year strftime('%Y', @dateTime)

Poznámka:

Některé SQL byly zjednodušeny pro účely ilustrace. Skutečný SQL je složitější pro zpracování širšího rozsahu hodnot.

Numerické funkce

platforma .NET SQL Přidáno do
-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
double.DegreesToRadians(stupně) radians(@degrees)
dvojitý. RadiansToDegrees(radiány) stupňů(@dradians)
doubleValue % d mod(@doubleValue; @d)
EF.Functions.Random() abs(random() / 9223372036854780000.0)
Math.Abs(value) abs(@value)
Math.Acos(hodnota) 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)
Math.Strop(d) ceiling(@d)
Math.Cos(d) cos(@d)
Math.Cosh(hodnota) cosh(@value)
Math.Exp(d) exp(@d)
Math.Floor(d) floor(@d)
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) zaokrouhlit(@d)
Math.Round(d, číslice) 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(hodnota) tanh(@value) EF Core 8.0
Math.Truncate(d) trunc(@d) EF Core 8.0

Tip

Kromě zde uvedených metod jsou také přeloženy odpovídající obecné matematické implementace a metody, stejně jako metody MathF. Například, Math.Sin, MathF.Sin, double.Sin a float.Sin všechna mapují na sin funkci v SQL.

Tip

Funkce SQL s předponou ef_ jsou vytvořeny EF Core.

Funkce řetězců

platforma .NET SQL
char.ToLower(c) lower(@c)
char.ToUpper(c) upper(@c)
EF. Functions.Collate(operand, kolace) @operand KOLACE @collation
EF. Functions.Glob(matchExpression; pattern) @matchExpression GLOBUS @pattern
EF. Functions.Like(matchExpression; pattern) @matchExpression JAKO @pattern
EF.Functions.Like(matchExpression, pattern, escapeCharacter) @matchExpression JAKO @pattern ESCAPE @escapeCharacter
Regex.IsMatch(input, pattern) @input REGEXP @pattern
string.Compare(strA, strB) CASE WHEN @strA = @strB THEN 0 ... KONEC
string.Concat(str0, str1) @str0 || @str1
string.IsNullOrEmpty(value) @value JE NULOVÁ HODNOTA NEBO @value = ''
string.IsNullOrWhiteSpace(hodnota) @value IS NULL NEBO odstranit mezery (@hodnota) = ''
stringValue.CompareTo(strB) CASE WHEN @stringValue = @strB THEN 0 ... KONEC
stringValue.Contains(value) instr(@stringValue; @value)> 0
stringValue.EndsWith(value) @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 délka(@stringValue)
Metoda stringValue.Replace(oldValue, newValue) nahradí starou hodnotu novou. 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)

Poznámka:

Některé SQL byly zjednodušeny pro účely ilustrace. Skutečný SQL je složitější pro zpracování širšího rozsahu hodnot.

Různé funkce

platforma .NET SQL
sbírka. Contains(item) @item V @collection
enumValue.HasFlag(flag) @enumValue & @flag = @flag
Nullable. GetValueOrDefault() coalesce(@nullable; 0)
Nullable.GetValueOrDefault(defaultValue) coalesce(@nullable, @defaultValue)

Viz také