Partilhar via


Named Type Constructor

Used to create instances of conceptual model nominal types such as Entity or Complex types.

[{identifier. }] identifier( [expression [{, expression }]] )

Arguments

  • identifier
    Value that is a simple or quoted identifier. For more information see, Identifiers
  • expression
    Attributes of the type that are assumed to be in the same order as they appear in the declaration of the type.

Return Value

Instances of named complex types and entity types.

Remarks

The following examples show how to construct nominal and complex types:

The expression below creates an instance of a Person type:

Person("abc", 12)

The expression below creates an instance of a complex type:

MyModel.ZipCode(‘98118’, ‘4567’)

The expression below creates an instance of a nested complex type:

MyModel.AddressInfo('My street address', 'Seattle', 'WA', MyModel.ZipCode('98118', '4567'))

The expression below creates an instance of an entity with a nested complex type:

MyModel.Person("Bill", MyModel.AddressInfo('My street address', 'Seattle', 'WA', MyModel.ZipCode('98118', '4567')))

The following example shows how to initialize a property of a complex type to null:MyModel.ZipCode(‘98118’, null)

Example

The following Entity SQL query uses the named type constructor to create an instance of a conceptual model type. The query is based on the AdventureWorks Sales Model. To compile and run this query, follow these steps:

  1. Follow the procedure in How to: Execute a Query that Returns StructuralType Results.

  2. Pass the following query as an argument to the ExecuteStructuralTypeQuery method:

SELECT VALUE AdventureWorksModel.SalesOrderDetail
    (o.SalesOrderID, o.SalesOrderDetailID, o.CarrierTrackingNumber,
    o.OrderQty, o.ProductID, o.SpecialOfferID, o.UnitPrice,
    o.UnitPriceDiscount, o.LineTotal, o.rowguid, o.ModifiedDate)
    FROM AdventureWorksEntities.SalesOrderDetails AS o

See Also

Concepts

Constructing Types
Entity SQL Reference