DbExpressionBuilder.New Method

 

Creates a new DbNewInstanceExpression. If the type argument is a collection type, the arguments specify the elements of the collection. Otherwise the arguments are used as property or column values in the new instance.

Namespace:   System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder
Assembly:  EntityFramework (in EntityFramework.dll)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticNew(TypeUsage, DbExpression[])

Creates a new DbNewInstanceExpression. If the type argument is a collection type, the arguments specify the elements of the collection. Otherwise the arguments are used as property or column values in the new instance.

System_CAPS_pubmethodSystem_CAPS_staticNew(TypeUsage, IEnumerable<DbExpression>)

Creates a new DbNewInstanceExpression. If the type argument is a collection type, the arguments specify the elements of the collection. Otherwise the arguments are used as property or column values in the new instance.


DbExpressionBuilder.New Method (TypeUsage, DbExpression[])

Creates a new DbNewInstanceExpression. If the type argument is a collection type, the arguments specify the elements of the collection. Otherwise the arguments are used as property or column values in the new instance.

public static DbNewInstanceExpression New(
	this TypeUsage instanceType,
	params DbExpression[] arguments
)

Parameters

instanceType
Type: System.Data.Entity.Core.Metadata.Edm.TypeUsage

The type of the new instance.

arguments
Type: System.Data.Entity.Core.Common.CommandTrees.DbExpression[]

Expressions that specify values of the new instances, interpreted according to the instance's type.

Return Value

Type: System.Data.Entity.Core.Common.CommandTrees.DbNewInstanceExpression

A new DbNewInstanceExpression with the specified type and arguments.

Exception Condition
ArgumentNullException

instanceTypeargumentsarguments

ArgumentException

instanceType or arguments is null, or arguments contains null.

If instanceType is a a collection type then every expression in arguments must have a result type that is promotable to the element type of the instanceType. if instanceType is a row type, arguments must contain as many expressions as there are columns in the row type, and the result type of each expression must be equal or promotable to the type of the corresponding column. A row type that does not declare any columns is invalid. if instanceType is an entity type, arguments must contain as many expressions as there are properties defined by the type, and the result type of each expression must be equal or promotable to the type of the corresponding property.


DbExpressionBuilder.New Method (TypeUsage, IEnumerable<DbExpression>)

Creates a new DbNewInstanceExpression. If the type argument is a collection type, the arguments specify the elements of the collection. Otherwise the arguments are used as property or column values in the new instance.

public static DbNewInstanceExpression New(
	this TypeUsage instanceType,
	IEnumerable<DbExpression> arguments
)

Parameters

instanceType
Type: System.Data.Entity.Core.Metadata.Edm.TypeUsage

The type of the new instance.

arguments
Type: System.Collections.Generic.IEnumerable<DbExpression>

Expressions that specify values of the new instances, interpreted according to the instance's type.

Return Value

Type: System.Data.Entity.Core.Common.CommandTrees.DbNewInstanceExpression

A new DbNewInstanceExpression with the specified type and arguments.

Exception Condition
ArgumentNullException

instanceType or arguments is null, or arguments contains null.

ArgumentException

arguments is empty or the result types of the contained expressions do not match the requirements of instanceType (as explained in the remarks section).

if instanceType is a a collection type then every expression in arguments must have a result type that is promotable to the element type of the instanceType. if instanceType is a row type, arguments must contain as many expressions as there are columns in the row type, and the result type of each expression must be equal or promotable to the type of the corresponding column. A row type that does not declare any columns is invalid. if instanceType is an entity type, arguments must contain as many expressions as there are properties defined by the type, and the result type of each expression must be equal or promotable to the type of the corresponding property.