Udostępnij za pośrednictwem


MULTISET

Creates an instance of a multiset from a list of values. All the values in the MULTISET constructor must be of a compatible type T. Empty multiset constructors are not allowed.

MULTISET ( expression [{, expression }] )
or
{ expression [{, expression }] }

Arguments

  • expression
    Any valid list of values.

Return Value

A collection of type MULTISET<T>.

Remarks

Entity SQL provides three kinds of constructors: row constructors, object constructors, and multiset (or collection) constructors. For more information, see Constructing Types.

The multiset constructor creates an instance of a multiset from a list of values. All the values in the constructor must be of a compatible type.

For example, the following expression creates a multiset of integers.

MULTISET(1, 2, 3)

{1, 2, 3}

Note

Nested multiset literals are only supported when a wrapping mutiset has a single multiset element; for example, {{1, 2, 3}}. When the wrapping multiset has multiple multiset elements (for example, {{1, 2}, {3, 4}}), nested multiset literals are not supported.

Example

The following Entity SQL query uses the MULTISET operator to create an instance of a multiset from a list of values. 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 product FROM AdventureWorksEntities.Products 
    AS product WHERE product.ListPrice IN MultiSet (@price1, @price2)

See Also

Concepts

Constructing Types
Entity SQL Reference