다음을 통해 공유


FLATTEN (Entity SQL)

Converts a collection of collections into a flattened collection. The new collection contains all the same elements as the old collection, but without a nested structure.

FLATTEN ( collection )

Arguments

  • collection
    Any valid expression that returns a collection of value collections to flatten into a single collection.

Remarks

FLATTEN is one of the Entity SQL set operators. All Entity SQL set operators are evaluated from left to right. See EXCEPT (Entity SQL) for precedence information for the Entity SQL set operators.

Example

The following Entity SQL query uses the FLATTEN operator to convert a collection of collections into a flattened collection. To compile and run this query, follow these steps:

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

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

FLATTEN(SELECT VALUE c.SalesOrderHeader From 
    AdventureWorksEntities.Contact as c)

This example produces the following output:

SalesOrderID: 43659
RevisionNumber: 16
OrderDate: 7/1/2001 12:00:00 AM
DueDate: 7/13/2001 12:00:00 AM
ShipDate: 7/8/2001 12:00:00 AM
Status: 1
OnlineOrderFlag: False
SalesOrderNumber: SO43659
PurchaseOrderNumber: PO522145787
AccountNumber: 10-4020-000676
CustomerID: 676
SalesPersonID: 279
TerritoryID: 5
ShipMethodID: 5
CreditCardID: 16281
CreditCardApprovalCode: 105041Vi84182
CurrencyRateID: SubTotal: 47020.9106
TaxAmt: 1971.5149
Freight: 616.0984
TotalDue: 49608.5239
Comment: rowguid: 79b65321-39ca-4115-9cba-8fe0903e12e6
ModifiedDate: 7/8/2001 12:00:00 AM
...

See Also

Concepts

Entity SQL Reference

Other Resources

Set Operators