Export (0) Print
Expand All

DefiningExpression Element (CSDL)

The DefiningExpression element in conceptual schema definition language (CSDL) contains an Entity SQL expression that defines a function in the conceptual model. For more information, see Function Element (CSDL) and Entity SQL Language.

Dd489503.note(en-us,VS.100).gifNote:
For validation purposes, a DefiningExpression element can contain arbitrary content. However, the Entity Framework will throw an exception at runtime if a DefiningExpression element does not contain valid Entity SQL.

Applicable Attributes

Any number of annotation attributes (custom XML attributes) may be applied to the DefiningExpression 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 uses a DefiningExpression element to define a function that returns the number of years since a book was published. The content of the DefiningExpression element is written in Entity SQL.

<Function Name="GetYearsInPrint" ReturnType="Edm.Int32" >
      <Parameter Name="book" Type="BooksModel.Book" />
      <DefiningExpression>
        Year(CurrentDateTime()) - Year(cast(book.PublishedDate as DateTime))
      </DefiningExpression>
    </Function>

See Also

Community Additions

ADD
Show:
© 2014 Microsoft