Partilhar via


ReferenceType Element (CSDL)

The ReferenceType element in conceptual schema definition language (CSDL) specifies a reference to an entity type. The ReferenceType element can be a child of the following elements:

The ReferenceType element is used when defining a parameter or return type for a function. For more information, see Function Element (CSDL).

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

Applicable Attributes

The table below describes the attributes that can be applied to the ReferenceType element.

Attribute Name Is Required Value

Type

Yes

The name of the entity type being referenced.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the ReferenceType 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 the ReferenceType element used as a child of a Parameter element in a model-defined function that accepts a reference to a Person entity type:

<Function Name="GetYearsEmployed" ReturnType="Edm.Int32">
  <Parameter Name="instructor">
    <ReferenceType Type="SchoolModel.Person" />
  </Parameter>
  <DefiningExpression>
  Year(CurrentDateTime()) - Year(cast(instructor.HireDate as DateTime))
  </DefiningExpression>
</Function>

The following example shows the ReferenceType element used as a child of a ReturnType element in a model-defined function that returns a reference to a Person entity type:

<Function Name="GetPersonReference">
    <Parameter Name="p" Type="SchoolModel.Person" />
    <ReturnType>
        <ReferenceType Type="SchoolModel.Person" />
    </ReturnType>
    <DefiningExpression>
          REF(p)
    </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