Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
En esta página se muestran los miembros de .NET que se traducen en qué funciones SQL al usar el proveedor de SQLite.
Funciones de agregado
| .NET | SQL | Agregado en |
|---|---|---|
| grupo.Promedio(x => x.Property) | AVG(Property) | |
| grupo. Average(x => x.DecimalProperty) | ef_avg(DecimalProperty) | EF Core 9.0 |
| group.Count() | COUNT(*) | |
| group.LongCount() | COUNT(*) | |
| grupo.Máximo(x => x.Propiedad) | MAX(Property) | |
| grupo.Min(x => x.Property) | MIN(Property) | |
| grupo.Sum(x => x.Property) | SUM(Property) | |
| grupo.Sum(x => x.DecimalProperty) | ef_sum(DecimalProperty) | EF Core 9.0 |
| cuerda. Concat(group. Select(x => x.Property)) | group_concat(Property, '') | |
| cuerda. Join(separator, group. Select(x => x.Property)) | group_concat(Property, @separator) |
Funciones binarias
| .NET | SQL | Agregado en |
|---|---|---|
| bytes.Contains(value) | instr(@bytes, char(@value)) > 0 | |
| bytes.Length | length(@bytes) | |
| bytes.SequenceEqual(second) | @bytes = @second | |
| EF.Functions.Hex(bytes) | 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. Functions.Unhex(value, ignoreChars) | unhex(@value, @ignoreChars) |
Funciones de conversión
| .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) |
Funciones de fecha y hora
| .NET | SQL | Agregado en |
|---|---|---|
| dateOnly.AddDays(value) | date(@dateOnly, @value || " días") | |
| dateOnly.AddMonths(months) | date(@dateOnly, @months || ' meses') | |
| dateOnly.AddYears(value) | date(@dateOnly, @value || " años") | |
| dateOnly.Day | strftime("%d", @dateOnly)) | |
| dateOnly.DayOfWeek | strftime("%w", @dateOnly)) | |
| dateOnly.DayOfYear | strftime("%j", @dateOnly)) | |
| DateOnly.FromDateTime(dateTime) | date(@dateTime) | |
| dateOnly.Month | strftime("%m", @dateOnly)) | |
| 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', 'start of day') # Fecha y hora actuales en hora local, inicio del día | |
| DateTime.UtcNow | datetime('now') | |
| dateTime.AddDays(value) | datetime(@dateTime, @value || ' días') | |
| dateTime.AddHours(value) | datetime(@dateTime, @d || " horas") | |
| dateTime.AddMilliseconds(value) | datetime(@dateTime, (@value / 1000.0) || ' segundos') | |
| dateTime.AddMinutes(value) | datetime(@dateTime, @value || ' minutos') | |
| dateTime.AddMonths(months) | datetime(@dateTime, @months || ' meses') | |
| dateTime.AddSeconds(value) | datetime(@dateTime, @value || ' segundos') | |
| dateTime.AddTicks(value) | datetime(@dateTime, (@value / 10000000.0) || ' segundos') | |
| dateTime.AddYears(value) | datetime(@dateTime, @value || ' años') | |
| dateTime.Date | datetime(@dateTime, "comienzo del día") | |
| 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:
Se ha simplificado parte del SQL con fines ilustrativos. El SQL actual es más complejo para manipular una gama más amplia de valores.
Funciones numéricas
| .NET | SQL | Agregado en |
|---|---|---|
| -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(degrees) | radians(@degrees) | |
| double.RadiansToDegrees(radians) | degrees(@dradians) | |
| doubleValue % d | mod(@doubleValue, @d) | |
| EF.Functions.Random() | abs(random() / 9223372036854780000.0) | |
| Math.Abs(value) | abs(@value) | |
| Math.Acos(value) | 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) | ceiling(@d) | |
| Math.Cos(d) | cos(@d) | |
| Math.Cosh(value) | 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) | round(@d) | |
| Math.Round(d, dígitos) | 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 |
Sugerencia
Además de los métodos enumerados aquí, también se traducen las implementaciones genéricas matemáticas y los métodos correspondientes y MathF. Por ejemplo, Math.Sin, MathF.Sin, double.Sin y float.Sin todos se asignan a la función sin en SQL.
Sugerencia
Funciones SQL con el prefijo ef_ son creadas por EF Core.
Funciones de cadena
| .NET | SQL |
|---|---|
| char.ToLower(c) | lower(@c) |
| char.ToUpper(c) | upper(@c) |
| EF. Functions.Collate(operando, intercalación) | @operand COTEJAR @collation |
| EF. Functions.Glob(matchExpression, pattern) | @matchExpression GLOB @pattern |
| EF. Functions.Like(matchExpression, pattern) | @matchExpression GUSTAR @pattern |
| EF. Functions.Like(matchExpression, pattern, escapeCharacter) | @matchExpression LIKE @pattern ESCAPE @escapeCharacter |
| Regex.IsMatch(input, pattern) | @input REGEXP @pattern |
| String.Compare(strA, strB) | CASE WHEN @strA = @strB THEN 0 ... FIN |
| cadena.Concat(str0, str1) | @str0 || @str1 |
| string.IsNullOrEmpty(value) | @value ES NULO OR @value = '' |
| string.IsNullOrWhiteSpace(value) | @value IS NULL OR trim(@value) = '' |
| stringValue.CompareTo(strB) | CASE WHEN @stringValue = @strB THEN 0 ... FIN |
| 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 | 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:
Se ha simplificado parte del SQL con fines ilustrativos. El SQL actual es más complejo para manipular una gama más amplia de valores.
Funciones varias
| .NET | SQL |
|---|---|
| collection.Contains(item) | @item EN @collection |
| enumValue.HasFlag(flag) | @enumValue & @flag = @flag |
| nullable.GetValueOrDefault() | coalesce(@nullable, 0) |
| nullable.GetValueOrDefault(defaultValue) | coalesce(@nullable, @defaultValue) |