DbExpressionBuilder.Constant Method

Definition

Creates a new DbConstantExpression.

Overloads

Constant(TypeUsage, Object)

Creates a new DbConstantExpression of the specified primitive type with the given constant value.

Constant(Object)

Creates a new DbConstantExpression with the given constant value.

Constant(TypeUsage, Object)

Creates a new DbConstantExpression of the specified primitive type with the given constant value.

C#
public static System.Data.Common.CommandTrees.DbConstantExpression Constant(this System.Data.Metadata.Edm.TypeUsage constantType, object value);

Parameters

constantType
TypeUsage

The type of the constant value.

value
Object

The constant value to represent.

Returns

A new DbConstantExpression with the given value and a result type of constantType.

Exceptions

value or constantType is null.

value is not an instance of a valid constant type, constantType does not represent a primitive type, or value is of a different primitive type than that represented by constantType.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Constant(Object)

Creates a new DbConstantExpression with the given constant value.

C#
public static System.Data.Common.CommandTrees.DbConstantExpression Constant(object value);

Parameters

value
Object

The constant value to represent.

Returns

A new DbConstantExpression with the given value.

Exceptions

value is null.

value is not an instance of a valid constant type.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1