dotConnect for DB2 Documentation
In This Topic
    Using Database-Specific Functions in Entity Framework
    In This Topic

    dotConnect for DB2 allows using DB2-specific functions in Entity SQL and LINQ to Entities. You can use these functions in your Entity SQL statements for Entity Framework v4 - v6.

    The following Entity SQL example is for ObjectContext only:

            var q = from c in db.PersonContacts.Where(@"Devart.Data.DB2.Soundex(it.LastName) == 
                Devart.Data.DB2.Soundex(@new)", new ObjectParameter("new", name))
                    select c;
    

    In LINQ to Entities, these functions can be used only for Entity Framework v4 - v6. These functions are members of the DB2Functions class, that is located in the Devart.Data.DB2.Entity assembly.

    The following example can be used both for ObjectContext and for DbContext:

            var q = from c in db.PersonContacts
                    where DB2Functions.Soundex(c.LastName, "Q") == DB2Functions.Soundex(name)
                    select c;
    ] [MySQL;PostgreSQL: ]

    Entity SQL function

    LINQ to Entities function

    Description

    ACOS Acos Returns the arc cosine of a number, in radians.
    ADD_MONTHS AddMonths Returns a datetime value that represents an argument value plus a specified number of months.
    ASCII Ascii Returns the ASCII code value of the leftmost character of the argument as an integer.
    ASIN Asin Returns the arc sine of a number, in radians.
    ATAN Atan Returns the arc tangent of a number, in radians.
    ATAN2 Atan2 Returns the arc tangent of x and y coordinates as an angle expressed in radians.
    ATANH Atanh Returns the hyperbolic arc tangent of a number, in radians.
    CHR Chr Returns the character that has the ASCII code value specified by the argument.
    COMPARE_DECFLOAT CompareDecfloat

    Returns a SMALLINT value that indicates whether the two arguments are equal or unordered, or whether one argument is greater than the other.

    The result is the following:

    • 0 - the arguments are exactly equal
    • 1 - expression1 is less than expression2
    • 2 - expression1 is greater than expression2
    • 3 - the arguments are unordered
    COS Cos Returns the cosine of a number.
    COSH Cosh Returns the hyperbolic cosine of a number.
    COT Cot Returns the cotangent of a number.
    DAYNAME DayName Returns the name of the day for the day portion of the argument, based on locale-name (if it is specified) or on the CURRENT LOCALE LC_TIME register value.
    DAYOFWEEK DayOfWeek Returns the day of the week from a value, where 1 is Sunday and 7 is Saturday.
    DAYOFWEEK_ISO DayOfWeekIso Returns the day of the week from a value, where 1 is Monday and 7 is Sunday.
    DAYOFYEAR DayOfYear Returns the day of the year from a value.
    DAYS Days Returns an integer representation of a date.
    DECFLOAT_FORMAT DecfloatFormat Returns the decimal floating-point representation of a value.
    DECRYPT_BIN DecryptBin Returns the result of decrypting encrypted data using a password string.
    DECRYPT_CHAR DecryptChar Returns the result of decrypting encrypted data using a password string.
    DEGREES Degrees Returns the number of degrees in the specified angle.
    DIFFERENCE Difference Returns a value from 0 to 4 representing the difference between the sounds of two strings based on applying the SOUNDEX function to the strings. 4 means the best possible sound match.
    DIGITS Digits Returns the number of degrees of an angle, specified in radians.
    ENCRYPT Encrypt Returns a value that is the result of encrypting a data string expression.
    EXP Exp Returns the base of the natural logarithm (e) raised to a power specified by the argument.
    GENERATE_UNIQUE GenerateUnique Returns a bit data character string that is unique compared to any other execution of the same function.
    GETHINT GetHint Returns the password hint if such is found.
    GREATEST Greatest Returns the maximum value in a set of values.
    HEX Hex Returns a hexadecimal representation of a value.
    INITCAP Initcap Returns a string with the first character of each word converted to uppercase and the rest to lowercase.
    JULIAN_DAY JulianDay Returns an integer value representing the number of days from January 1, 4712 B.C. to the date specified in the argument.
    LAST_DAY LastDay Returns a datetime value that represents the last day of the month of the argument.
    LEAST Least Returns the minimum value in a set of values.
    LN Ln Returns the natural logarithm of a number.
    LOG10 Log10 Return the common logarithm (base 10) of a number.
    LOWER Lower Returns a string in which all characters have been converted to lowercase characters using the rules from the Unicode standard associated with the specified locale.
    LTRIM Ltrim Removes blanks from the beginning of a string.
    mod Mod Returns the remainder.
    MIDNIGHT_SECONDS MidnightSeconds Returns an integer value representing the number of seconds between midnight and a specified time value.
    MONTHNAME MonthName Returns a character string containing the name of the month (for example, January) for the month portion of expression,, based on locale-name (if it is specified) or on the CURRENT LOCALE LC_TIME register value.
    MONTHS_BETWEEN MonthsBetween Returns an estimate of the number of months between the specified values.
    NEXT_DAY NextDay Returns a datetime value that represents the first weekday, specified in the second argument, that is later than the date, specified in the first argument.
    QUARTER Quarter Returns an integer that represents the quarter of the year in which the specified date resides.
    RADIANS Radians Returns the number of radians for the specified value in degrees.
    RAND Rand Returns a random number.
    REPEAT Repeat Returns a character string composed of the first argument strings, repeated a specified by the second argument number times.
    RPAD Rpad Returns a string that is padded on the right with the specified character, string, or with blanks.
    RTRIMRTRIM Rtrim Removes blanks from the end of a string.
    SIGN Sign Returns an indicator of the sign of an expression.
    SIN Sin Returns the sine of a number.
    SINH Sinh Returns the hyperbolic sine of a number.
    SOUNDEX Soundex Returns a 4-character code representing the sound of the words in the argument. This result can be compared with the sound of other strings.
    SPACE Space Returns a character string that consists of a specified number of blanks.
    SQRT Sqrt Returns the square root of a number.
    TAN Tan Returns the tangent of a number.
    TANH Tanh Returns the hyperbolic tangent of a number.
    TIMESTAMP_FORMAT TimestampFormat Returns a timestamp from the specified character string that has been interpreted using format template, precision, and locale (if such are specified).
    TRANSLATE Translate Returns a string in which one or more characters in a string are converted to other characters.
    TRUNC_TIMESTAMP TruncTimestamp Truncates the specified timestamp to the specified units.
    UPPER Upper Returns a string in which all the characters have been converted to uppercase characters.
    VARCHAR_BIT_FORMAT VarcharBitFormat Returns a bit string representation of the specified character string that has been formatted using a character template (if such is specified).
    VARCHAR_FORMAT VarcharFormat Returns a CHARACTER representation of the specified timestamp (argument1), formatted according to a template (if such is specified).
    VARCHAR_FORMAT_BIT VarcharFormatBit Returns a character representation of the specified bit string that has been formatted using a character template (if such is specified).
    WEEK Week Returns the week of the year from a value, where the week starts with Sunday.
    WEEK_ISO WeekIso Returns the week of the year from a value, where the week starts with Monday.

    See Also

    Entity Framework  | Entity Framework Canonical Functions