Megosztás a következőn keresztül:


TypeRef Element (CSDL)

The TypeRef element in conceptual schema definition language (CSDL) provides a reference to an existing named type. The TypeRef element can be a child of the CollectionType element, which is used to specify that a function has a collection as a parameter or return type. For more information, see Function Element (CSDL).

A TypeRef element can have the following child elements (in the order listed):

Applicable Attributes

The following table describes the attributes that can be applied to the TypeRef element. Note that the DefaultValue, MaxLength, FixedLength, Precision, Scale, Unicode, and Collation attributes are only applicable to EDMSimpleTypes. For more information, see Facets (CSDL) and Conceptual Model Types (CSDL).

Attribute Name Is Required Value

Type

No

The name of the type being referenced.

Nullable

No

True (the default value) or False depending on whether the property can have a null value.

Ee476605.note(en-us,VS.100).gifNote:
In the version of CSDL indicated by the https://schemas.microsoft.com/ado/2006/04/edm namespace, a complex type property must have Nullable="False".

DefaultValue

No

The default value of the property.

MaxLength

No

The maximum length of the property value.

FixedLength

No

True or False depending on whether the property value will be stored as a fixed length string.

Precision

No

The precision of the property value.

Scale

No

The scale of the property value.

Unicode

No

True or False depending on whether the property value will be stored as a Unicode string.

Collation

No

A string that specifies the collating sequence to be used in the data source.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the CollectionType element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.

Example

The following example shows a model-defined function that uses the TypeRef element (as a child of a CollectionType element) to specify that the function accepts a collection of Department entity types.

<Function Name="GetAvgBudget">
     <Parameter Name="Departments">
         <CollectionType>
            <TypeRef Type="SchoolModel.Department"/>
         </CollectionType>
          </Parameter>
      <ReturnType Type="Collection(Edm.Decimal)"/>
      <DefiningExpression>
            SELECT VALUE AVG(d.Budget) FROM Departments AS d
      </DefiningExpression>
</Function>

See Also

Concepts

Entity Framework Overview
CSDL Specification
FunctionImport Element (CSDL)

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools