DbFunctions Class

Definition

Provides CLR methods that get translated to database functions when used in LINQ to Entities queries. The methods on this class are accessed via Functions.

public class DbFunctions
public sealed class DbFunctions
type DbFunctions = class
Public Class DbFunctions
Public NotInheritable Class DbFunctions
Inheritance
DbFunctions

Extension Methods

Like(DbFunctions, String, String)

An implementation of the SQL LIKE operation. On relational databases this is usually directly translated to SQL.

Note that if this function is translated into SQL, then the semantics of the comparison will depend on the database configuration. In particular, it may be either case-sensitive or case-insensitive. If this function is evaluated on the client, then it will always use a case-insensitive comparison.

Like(DbFunctions, String, String, String)

An implementation of the SQL LIKE operation. On relational databases this is usually directly translated to SQL.

Note that if this function is translated into SQL, then the semantics of the comparison will depend on the database configuration. In particular, it may be either case-sensitive or case-insensitive. If this function is evaluated on the client, then it will always use a case-insensitive comparison.

Collate<TProperty>(DbFunctions, TProperty, String)

Explicitly specifies a collation to be used in a LINQ query. Can be used to generate fragments such as WHERE customer.name COLLATE 'de_DE' = 'John Doe'.

The available collations and their names vary across databases, consult your database's documentation for more information.

Contains(DbFunctions, String, String)

A DbFunction method stub that can be used in LINQ queries to target the SQL Server CONTAINS store function.

Contains(DbFunctions, String, String, Int32)

A DbFunction method stub that can be used in LINQ queries to target the SQL Server CONTAINS store function.

DataLength(DbFunctions, Byte[])

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<Boolean>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<DateTime>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<DateTimeOffset>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<Decimal>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<Double>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<Guid>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, Nullable<TimeSpan>)

Returns the number of bytes used to represent any expression.

DataLength(DbFunctions, String)

Returns the number of bytes used to represent any expression.

DateDiffDay(DbFunctions, DateTime, DateTime)

Counts the number of day boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(DAY,startDate,endDate).

DateDiffDay(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of day boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(DAY,startDate,endDate).

DateDiffDay(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of day boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(DAY,startDate,endDate).

DateDiffDay(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of day boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(DAY,startDate,endDate).

DateDiffHour(DbFunctions, DateTime, DateTime)

Counts the number of hour boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(HOUR,startDate,endDate).

DateDiffHour(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of hour boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(HOUR,startDate,endDate).

DateDiffHour(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of hour boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(HOUR,startDate,endDate).

DateDiffHour(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of hour boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(HOUR,startDate,endDate).

DateDiffHour(DbFunctions, Nullable<TimeSpan>, Nullable<TimeSpan>)

Counts the number of hour boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(HOUR,startDate,endDate).

DateDiffHour(DbFunctions, TimeSpan, TimeSpan)

Counts the number of hour boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(HOUR,startDate,endDate).

DateDiffMicrosecond(DbFunctions, DateTime, DateTime)

Counts the number of microsecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MICROSECOND,startDate,endDate).

DateDiffMicrosecond(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of microsecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MICROSECOND,startDate,endDate).

DateDiffMicrosecond(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of microsecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MICROSECOND,startDate,endDate).

DateDiffMicrosecond(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of microsecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MICROSECOND,startDate,endDate).

DateDiffMicrosecond(DbFunctions, Nullable<TimeSpan>, Nullable<TimeSpan>)

Counts the number of microsecond boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(MICROSECOND,startDate,endDate).

DateDiffMicrosecond(DbFunctions, TimeSpan, TimeSpan)

Counts the number of microsecond boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(MICROSECOND,startDate,endDate).

DateDiffMillisecond(DbFunctions, DateTime, DateTime)

Counts the number of millisecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MILLISECOND,startDate,endDate).

DateDiffMillisecond(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of millisecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MILLISECOND,startDate,endDate).

DateDiffMillisecond(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of millisecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MILLISECOND,startDate,endDate).

DateDiffMillisecond(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of millisecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MILLISECOND,startDate,endDate).

DateDiffMillisecond(DbFunctions, Nullable<TimeSpan>, Nullable<TimeSpan>)

Counts the number of millisecond boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(MILLISECOND,startDate,endDate).

DateDiffMillisecond(DbFunctions, TimeSpan, TimeSpan)

Counts the number of millisecond boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(MILLISECOND,startDate,endDate).

DateDiffMinute(DbFunctions, DateTime, DateTime)

Counts the number of minute boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MINUTE,startDate,endDate).

DateDiffMinute(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of minute boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MINUTE,startDate,endDate).

DateDiffMinute(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of minute boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MINUTE,startDate,endDate).

DateDiffMinute(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of minute boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MINUTE,startDate,endDate).

DateDiffMinute(DbFunctions, Nullable<TimeSpan>, Nullable<TimeSpan>)

Counts the number of minute boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(MINUTE,startDate,endDate).

DateDiffMinute(DbFunctions, TimeSpan, TimeSpan)

Counts the number of minute boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(MINUTE,startDate,endDate).

DateDiffMonth(DbFunctions, DateTime, DateTime)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MONTH,startDate,endDate).

DateDiffMonth(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MONTH,startDate,endDate).

DateDiffMonth(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MONTH,startDate,endDate).

DateDiffMonth(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(MONTH,startDate,endDate).

DateDiffNanosecond(DbFunctions, DateTime, DateTime)

Counts the number of nanosecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(NANOSECOND,startDate,endDate).

DateDiffNanosecond(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of nanosecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(NANOSECOND,startDate,endDate).

DateDiffNanosecond(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of nanosecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(NANOSECOND,startDate,endDate).

DateDiffNanosecond(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of nanosecond boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(NANOSECOND,startDate,endDate).

DateDiffNanosecond(DbFunctions, Nullable<TimeSpan>, Nullable<TimeSpan>)

Counts the number of nanosecond boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(NANOSECOND,startDate,endDate).

DateDiffNanosecond(DbFunctions, TimeSpan, TimeSpan)

Counts the number of nanosecond boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(NANOSECOND,startDate,endDate).

DateDiffSecond(DbFunctions, DateTime, DateTime)

Counts the number of second boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(SECOND,startDate,endDate).

DateDiffSecond(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of second boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(SECOND,startDate,endDate).

DateDiffSecond(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of second boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(SECOND,startDate,endDate).

DateDiffSecond(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of second boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(SECOND,startDate,endDate).

DateDiffSecond(DbFunctions, Nullable<TimeSpan>, Nullable<TimeSpan>)

Counts the number of second boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(SECOND,startDate,endDate).

DateDiffSecond(DbFunctions, TimeSpan, TimeSpan)

Counts the number of second boundaries crossed between the startTimeSpan and endTimeSpan. Corresponds to SQL Server's DATEDIFF(SECOND,startDate,endDate).

DateDiffWeek(DbFunctions, DateTime, DateTime)

Counts the number of week boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(WEEK,startDate,endDate).

DateDiffWeek(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of week boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(WEEK,startDate,endDate).

DateDiffWeek(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of week boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(WEEK,startDate,endDate).

DateDiffWeek(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of week boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(WEEK,startDate,endDate).

DateDiffYear(DbFunctions, DateTime, DateTime)

Counts the number of year boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(YEAR,startDate,endDate).

DateDiffYear(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of year boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(YEAR,startDate,endDate).

DateDiffYear(DbFunctions, Nullable<DateTime>, Nullable<DateTime>)

Counts the number of year boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(YEAR,startDate,endDate).

DateDiffYear(DbFunctions, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Counts the number of year boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(YEAR,startDate,endDate).

DateFromParts(DbFunctions, Int32, Int32, Int32)

Initializes a new instance of the DateTime structure to the specified year, month, day. Corresponds to the SQL Server's DATEFROMPARTS(year, month, day).

DateTime2FromParts(DbFunctions, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, fractions, and precision. Corresponds to the SQL Server's DATETIME2FROMPARTS (year, month, day, hour, minute, seconds, fractions, precision).

DateTimeFromParts(DbFunctions, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, and millisecond. Corresponds to the SQL Server's DATETIMEFROMPARTS(year, month, day, hour, minute, second, millisecond).

DateTimeOffsetFromParts(DbFunctions, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Initializes a new instance of the DateTimeOffset structure to the specified year, month, day, hour, minute, second, fractions, hourOffset, minuteOffset and precision. Corresponds to the SQL Server's DATETIMEOFFSETFROMPARTS (year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision).

FreeText(DbFunctions, String, String)

A DbFunction method stub that can be used in LINQ queries to target the SQL Server FREETEXT store function.

FreeText(DbFunctions, String, String, Int32)

A DbFunction method stub that can be used in LINQ queries to target the SQL Server FREETEXT store function.

IsDate(DbFunctions, String)

Validate if the given string is a valid date. Corresponds to the SQL Server's ISDATE('date').

SmallDateTimeFromParts(DbFunctions, Int32, Int32, Int32, Int32, Int32)

Initializes a new instance of the DateTime structure to the specified year, month, day, hour and minute. Corresponds to the SQL Server's SMALLDATETIMEFROMPARTS (year, month, day, hour, minute).

TimeFromParts(DbFunctions, Int32, Int32, Int32, Int32, Int32)

Initializes a new instance of the TimeSpan structure to the specified hour, minute, second, fractions, and precision. Corresponds to the SQL Server's TIMEFROMPARTS (hour, minute, seconds, fractions, precision).

Applies to