Table of Contents

Class DbFunctionsExtensions

Namespace
Microsoft.EntityFrameworkCore
Assembly
Microsoft.EntityFrameworkCore.dll

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 static class DbFunctionsExtensions
Inheritance
DbFunctionsExtensions
Inherited Members

Remarks

See Database functions for more information and examples.

Methods

Like(DbFunctions, string?, string?)

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

public static bool Like(this DbFunctions _, string? matchExpression, string? pattern)

Parameters

_ DbFunctions

The DbFunctions instance.

matchExpression string

The string that is to be matched.

pattern string

The pattern which may involve wildcards %,_,[,],^.

Returns

bool

true if there is a match.

Remarks

Note that the semantics of the comparison will depend on the database configuration. In particular, it may be either case-sensitive or case-insensitive.

This DbFunction method has no in-memory implementation and will throw if the query switches to client-evaluation. This can happen if the query contains one or more expressions that could not be translated to the store.

Like(DbFunctions, string?, string?, string?)

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

public static bool Like(this DbFunctions _, string? matchExpression, string? pattern, string? escapeCharacter)

Parameters

_ DbFunctions

The DbFunctions instance.

matchExpression string

The string that is to be matched.

pattern string

The pattern which may involve wildcards %,_,[,],^.

escapeCharacter string

The escape character (as a single character string) to use in front of %,_,[,],^ if they are not used as wildcards.

Returns

bool

true if there is a match.

Remarks

Note that the semantics of the comparison will depend on the database configuration. In particular, it may be either case-sensitive or case-insensitive.

This DbFunction method has no in-memory implementation and will throw if the query switches to client-evaluation. This can happen if the query contains one or more expressions that could not be translated to the store.

Random(DbFunctions)

A random double number generator which generates a number between 0 and 1, exclusive.

public static double Random(this DbFunctions _)

Parameters

_ DbFunctions

The DbFunctions instance.

Returns

double

A random double number between 0 and 1, exclusive.

Remarks

This DbFunction method has no in-memory implementation and will throw if the query switches to client-evaluation. This can happen if the query contains one or more expressions that could not be translated to the store.