SQLite EF Core Sağlayıcısının İşlev Eşlemeleri

Bu sayfada, SQLite sağlayıcısı kullanılırken hangi .NET üyelerinin hangi SQL işlevlerine çevrildiği gösterilir.

Toplama işlevleri

Sorgularda toplama işlevlerini kullanma hakkında genel bilgi için bkz. Toplama işlevleri.

.NET SQL eklendi
grup.Ortalama(x => x.Property) AVG(Özellik)
grup.Average(x => x.DecimalProperty) ef_avg(DecimalProperty) EF Core 9.0
grup. Count() COUNT(*)
grup. LongCount() COUNT(*)
grup.Max(x => x.Property) MAX(Özellik)
grup.Min(x => x.Property) MIN(Özellik)
grup. Sum(x => x.Property) SUM(Özellik)
grup.Sum(x => x.DecimalProperty) ef_sum(DecimalProperty) EF Core 9.0
string.Concat(group.Select(x => x.Property)) group_concat(Özellik, '')
string.Concat(group.OrderBy(x => x.Other).Select(x => x.Property)) group_concat(Özellik, '' ORDER BY Other) EF Core 11.0
string.Join(ayırıcı, grup.Select(x => x.Property)) group_concat(Özellik, @separator)
string.Join(separator, group.OrderBy(x => x.Other).Select(x => x.Property)) group_concat(Özellik, @separator ORDER BY Other) EF Core 11.0

İkili işlevler

.NET SQL eklendi
bayt.içerir(value) instr(@bytes, char(@value)) > 0
Bayt. Uzunluk uzunluk(@bytes)
Bayt. SequenceEqual(saniye) @bytes = @second
EF. Functions.Hex(bayt) hex(@bytes)
EF.Functions.Substr(baytlar, startIndex) substring(@bytes, @startIndex)
EF.Functions.Substr(bytes, startIndex, length) substr(@bytes, @startIndex, @length)
EF.Functions.Unhex(value) unhex(@value)
EF.Functions.Unhex(value, ignoreChars) unhex(@value, @ignoreChars))

Dönüştürme işlevleri

.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 METİN)
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 METİN)
uintValue.ToString() CAST(@uintValue AS TEXT)
ushortValue.ToString() CAST(@ushortValue AS TEXT)

Tarih ve saat işlevleri

.NET SQL eklendi
dateOnly.AddDays(değer) date(@dateOnly, @value || 'gün')
dateOnly.AddMonths(aylar) date(@dateOnly, @months || 'aylar')
dateOnly.AddYears(değer) date(@dateOnly, @value || 'yıllar')
dateOnly.Day strftime('%d', @dateOnly)
dateOnly.DayOfWeek strftime('%w', @dateOnly)
dateOnly.YılınGünü strftime('%j', @dateOnly)
DateOnly.FromDateTime(dateTime) date(@dateTime)
dateOnly.Month strftime('%m', @dateOnly)
dateOnly.Yıl strftime('%Y', @dateOnly)
sadeceTarih.GünNumarası CAST(julianday(@dateOnly) - julianday('0001-01-01') AS INTEGER) EF Core 10.0
DateTime.Now datetime('şimdi', 'yerelzaman')
DateTime.Today datetime('now', 'localtime', 'günün başlangıcı')
DateTime.UtcNow datetime('now')
dateTime.AddDays(değer) datetime(@dateTime, @value || 'gün')
dateTime.AddHours(değer) datetime(@dateTime, @d || ' saat')
dateTime.AddMilliseconds(değer) datetime(@dateTime, (@value / 1000.0) || 'saniye')
dateTime.AddMinutes(değer) datetime(@dateTime, @value || ' dakika')
dateTime.AddMonths(aylar) datetime(@dateTime, @months || 'aylar')
dateTime.AddSeconds(değer) datetime(@dateTime, @value || 'saniye')
dateTime.AddTicks(değer) datetime(@dateTime, (@value / 10000000.0) || 'saniye')
dateTime.AddYears(değer) datetime(@dateTime, @value || 'yıl')
dateTime.Date datetime(@dateTime, 'günün başlangıcı')
dateTime.Day strftime('%d', @dateTime)
dateTime.DayOfWeek strftime('%w', @dateTime)
dateTime.DayOfYear strftime('%j', @dateTime)
tarihZaman.Saat strftime('%H', @dateTime)
dateTime.Milisecond (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 zaman(@tarihSaat)
dateTime.Year strftime('%Y', @dateTime)

Not

Bazı SQL'ler çizim amacıyla basitleştirilmiştir. Gerçek SQL, daha geniş bir değer aralığını işlemek için daha karmaşıktır.

Sayısal işlevler

.NET SQL eklendi
-desimalDeğer ef_negate(@decimalValue) fonksiyon, @decimalValue değerini negatif yapar.
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(derece) radyan(@degrees)
çift. RadyanToDegrees(radyan) derece(@dradians)
doubleValue % d mod(@doubleValue, @d)
EF.Functions.Random() abs(random() / 9223372036854780000.0)
Math.Abs(değer) abs(@value)
Math.Acos(değer) 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.Ceiling(d) fonksiyonu, d değerini yukarıya yuvarlar. tavan(@d)
Math.Cos(d) cos(@d)
Math.Cosh(değer) cosh(@value)
Math.Exp(d) exp(@d)
Math.Floor(d) taban(@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) round(@d)
Math.Round(d, basamaklar) round(@d, @digits)
Math.Sign(d) – sayının işaretini belirler işaret(@d) EF Core 8.0
Math.Sin(a) sin(@a) EF Core 8.0
Math.Sinh(değer) 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(değer) tanh(@value) EF Core 8.0
Math.Truncate(d) trunc(@d) EF Core 8.0

İpucu

Burada listelenen yöntemlere ek olarak, ilgili genel matematik uygulamaları ve MathF yöntemleri de çevrilir. Örneğin, Math.Sin, MathF.Sin, double.Sin, ve float.Sin tümü SQL'deki sin işlevine eşlenir.

İpucu

ef_ ön ekli SQL işlevleri EF Core tarafından oluşturulur.

Dize işlevleri

.NET SQL
char.ToLower(c) lower(@c)
char.ToUpper(c) upper(@c)
EF.Functions.Collate(operand, sıralama) @operand SIRALAMA @collation
EF.Functions.Glob(matchExpression, pattern) @matchExpression GLOB @pattern
EF.Functions.Like(matchExpression, desen) @matchExpression GİBİ @pattern
EF.Functions.Like(matchExpression, pattern, escapeCharacter) @matchExpression GİBİ @pattern KAÇIŞ @escapeCharacter
Regex.IsMatch(giriş, desen) @input REGEXP @pattern
string.Compare(strA, strB) DURUMDA @strA = @strB SONUÇ 0 ... SON
string.Concat(str0, str1) @str0 || @str1
string.IsNullOrEmpty(değer) @value IS NULL VEYA @value = ''
string.IsNullOrWhiteSpace(değer) @value NULL VEYA trim(@value)=''
stringValue.CompareTo(strB) DURUMDA @stringValue = @strB SONUÇ 0 ... SON
stringValue.Contains(değer) instr(@stringValue, @value)> 0
stringValue.EndsWith(değer) @stringValue LIKE '%' || @value
stringValue.FirstOrDefault() substr(@stringValue, 1, 1)
stringValue.IndexOf(değer) instr(@stringValue, @value) - 1
stringValue.LastOrDefault() substring(@stringValue, length(@stringValue), 1)
stringValue.Uzunluk uzunluk(@stringValue)
stringValue.Replace(eskiDeğer, yeniDeğer) replace(@stringValue, @oldValue, @newValue))
stringValue.StartsWith(değer) @stringValue LIKE @value || '%'
stringValue.Substring(startIndex) alt dize(@stringValue, @startIndex + 1)
stringValue.Substring(startIndex, length) alt dize(@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)

Not

Bazı SQL'ler çizim amacıyla basitleştirilmiştir. Gerçek SQL, daha geniş bir değer aralığını işlemek için daha karmaşıktır.

Çeşitli işlevler

.NET SQL
koleksiyon.Contains(item) @item İÇİNDE @collection
enumValue.HasFlag(flag) @enumValue & @flag = @flag
nullable.GetValueOrDefault() coalesce(@nullable, 0)
Boş Olabilir.GetValueOrDefault(defaultValue) coalesce(@nullable, @defaultValue)

Ayrıca bkz.