-
Notifications
You must be signed in to change notification settings - Fork 383
Translations
Laurents Meyer edited this page Mar 10, 2024
·
8 revisions
Entity Framework Core allows providers to translate query expressions to SQL for database evaluation. For example, MySQL supports regular expression operations, and the MySQL EF Core provider automatically translates .NET's Regex.IsMatch
to use this feature. Since evaluation happens at the server, table data doesn't need to be transferred to the client (saving bandwidth), and in some cases indexes can be used to speed things up. The same C# code on other providers will trigger client evaluation.
.NET | SQL |
---|---|
EF.Functions.Degrees(radians) | DEGREES(X) |
EF.Functions.Radians(degrees) | RADIANS(X) |
Math.Abs(value) | ABS(X) |
Math.Acos(d) | ACOS(X) |
Math.Asin(d) | ASIN(X) |
Math.Atan(d) | ATAN(X) |
Math.Atan2(y, x) | ATAN2(Y,X) |
Math.Ceiling(d) | CEILING(X) |
Math.Cos(d) | COS(X) |
Math.Exp(d) | EXP(X) |
Math.Floor(d) | FLOOR(X) |
Math.Log(d) | LOG(X) |
Math.Log10(d) | LOG10(X) |
Math.Max(x, y) | GREATEST(value1,value2,...) |
Math.Min(x, y) | LEAST(value1,value2,...) |
Math.Pow(x, y) | POW(X,Y) |
Math.Round(d) | ROUND(X) |
Math.Round(d, decimals) | ROUND(X,D) |
Math.Sin(a) | SIN(X) |
Math.Sign(value) | SIGN(X) |
Math.Sqrt(d) | SQRT(X) |
Math.Tan(a) | TAN(X) |
Math.Truncate(d) | TRUNCATE(X,D) |
.NET | SQL |
---|---|
EF.Functions.Like(matchExpression, pattern) | expr LIKE pat [ESCAPE 'escape_char'] |
EF.Functions.Like(matchExpression, pattern, escapeCharacter) | expr LIKE pat [ESCAPE 'escape_char'] |
string.IsNullOrWhiteSpace(value) | ISNULL(expr), TRIM([remstr FROM] str) |
string.Concat(value1, value2, ...) | CONCAT(str1,str2,...) |
stringValue.Contains(value) | expr LIKE pat [ESCAPE 'escape_char'], LOCATE(substr,str) |
stringValue.EndsWith(value) | expr LIKE pat [ESCAPE 'escape_char'], RIGHT(str,len) |
stringValue.FirstOrDefault() | SUBSTRING(str,pos,len) |
stringValue.IndexOf(value) | LOCATE(substr,str) |
stringValue.IndexOf(value, startIndex) | LOCATE(substr,str,pos) |
stringValue.LastOrDefault() | SUBSTRING(str,pos,len), CHAR_LENGTH(str) |
stringValue.Length | CHAR_LENGTH(str) |
stringValue.PadLeft(length) | LPAD(str,len,padstr) |
stringValue.PadLeft(length, char) | LPAD(str,len,padstr) |
stringValue.PadRight(length) | RPAD(str,len,padstr) |
stringValue.PadRight(length, char) | RPAD(str,len,padstr) |
stringValue.Replace(oldValue, newValue) | REPLACE(str,from_str,to_str) |
stringValue.StartsWith(value) | expr LIKE pat [ESCAPE 'escape_char'], LEFT(str,len) |
stringValue.Substring(startIndex, length) | SUBSTRING(str,pos,len) |
stringValue.ToLower() | LOWER(str) |
stringValue.ToUpper() | UPPER(str) |
stringValue.Trim() | TRIM([remstr FROM] str) |
stringValue.Trim(trimChar) | TRIM([remstr FROM] str) |
stringValue.TrimEnd() | TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) |
stringValue.TrimEnd(trimChar) | TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) |
stringValue.TrimStart() | TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) |
stringValue.TrimStart(trimChar) | TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) |
Regex.IsMatch(stringValue, "^A+") | expr REGEXP pat |
.NET | SQL |
---|---|
bytesArray.ElementAt(index) | ASCII(SUBSTRING(str, start, extract)) |
.NET | SQL |
---|---|
Guid.NewGuid() | UUID() |
EF.Functions.Hex(value) | HEX(str) |
EF.Functions.Unhex(value) | UNHEX(str) |