Send feedback on this topic.
Teradata.Client.Provider
Teradata SQL Functions
.NET Data Provider for Teradata > Developer's Guide > Teradata Entity Framework Core Provider > Teradata Implementation Specifics > Teradata SQL Functions
.NET Framework  This feature is not supported by the .NET Framework implementation of the Data Provider.

Overview

The EFCore Provider supports a set of Teradata SQL Functions that can be used in LINQ queries. These functions are implemented in the Teradata.EntityFrameworkCore namespace and can be invoked using the EF.Functions class.

The following example demonstrates how the Teradata SQL Function InitCap can be used in a LINQ query:

InitCap Query
Copy Code
    var customers = db.Customers
        .Select(c => new
        {
            name = EF.Functions.InitCap(c.CustomerName),
            contact = c.ContactName
        });

With the exception of the Random() function, at least one of the arguments passed to these functions must be a reference to an element in your Model (i.e. they must contain a reference to a table column).

Supported Teradata SQL Functions

Please refer to the Teradata SQL Functions, Operators, Expressions and Predicates manual for more information about these functions.

Aggregate Functions Function Description Arguments Return Value
StdDev_Pop(expression) Returns population standard deviation for the data points. expression: Decimal or Double Double
StdDev_Samp(expression) Returns the sample standard deviation for the data points. expression: Decimal or Double Double
Var_Pop(expression) Returns the population variance for the data points. expression: Decimal or Double Double
Var_Samp(expression) Returns the sample variance for the data points. expression: Decimal or Double Double
Generic Functions Function Description Arguments Return Value
StringFunction(functionName, arg1 [... ,arg6]) Executes a Teradata function that returns a string. functionName: String
arg1, ..., arg6: Object
String
Arithmetic Functions Function Description Arguments Return Value
Degrees(value) Returns the input value, in radians, converted to degrees. value: Object (numeric) Double
Radians(value) Returns the input value, in degrees, converted to radians. value: Object (numeric) Double
Random(lowerBound, upperBound) Returns a random number in the range lowerBound to upperBound. lowerBound, upperBound: Int32 Int32
Width_Bucket(expression) Returns the number of the partition to which an expression is assigned. expression, lowerBound, upperBound: Decimal or Double
count: Int32
Int32
NullIfZero(expression) Returns Null if the expression is Zero, otherwise returns the expression value. expression: Any numeric Same as expression
ZeroIfNull(expression) Returns Zero if the expression is Null, otherwise returns the expression value. expression: Any numeric Same as expression
String Functions Function Description Arguments Return Value
Ascii(arg) Returns the decimal representation of the first character in arg. arg: String Double
Char2hexint(StringArg) Returns the hexadecimal representation of StringArgument StringArg: String String
Chr(numeric_exp) Returns the Latin ASCII character given a numeric code value. numeric_exp: Double or Decimal String
InitCap(string_arg) Modifies a string argument and returns the string with the first character in each word in uppercase and all other characters in lowercase. string_arg: String String
OTranslate(input, fromChars, toChars) Returns a string in which those characters in the input string which match a character in fromChars are replaced by the corresponding character in toChars. input, fromChars, toChars: String String
Reverse(string) Returns the input string with the characters in reverse order. string: String String
Soundex(string) Returns a string that represents the Soundex code for the input string. string: String String
Date and Time Functions Function Description Arguments Return Value
DateDiffDays(start, end) Returns the difference, in days, between the start and end expressions. start, end: DateTime or DateTimeOffset Int32
DateDiffHours(start, end) Returns the difference, in hours, between the start and end expressions. start, end: Time, DateTime or DateTimeOffset Int32
DateDiffMinutes(start, end) Returns the difference, in minutes, between the start and end expressions. start, end: Time, DateTime or DateTimeOffset Int32
DateDiffMonths(start, end) Returns the difference, in months, between the start and end expressions start, end: DateTime or DateTimeOffset Int32
DateDiffSeconds(start, end) Returns the difference, in seconds, between the start and end expressions. start, end: Time, DateTime or DateTimeOffset Int32
DateDiffYears(start, end) Returns the difference, in years, between the start and end expressions. start, end: DateTime or DateTimeOffset Int32
Last_Day(timestamp) Returns the date of the last day of the month that contains the timestamp value. timestamp: DateTime or DateTimeOffset DateTime
Next_Day(timestamp, day) Returns the date of the first 'day' after the date specified by timestamp. timestamp: DateTime or DateTimeOffset
day: String [MON, TUE, ...]
DateTime
Session Properties Function Description Arguments Return Value
Current_User() Returns the current user name. n/a String
Database() Returns the current database name. n/a String
Profile() Returns the current user's profile. n/a String