Duration (Pacific Standard Time):
To (Pacific Standard Time):
  • None
User Action:
  • None

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.

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.


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" />
        Year(CurrentDateTime()) - Year(cast(book.PublishedDate as DateTime))

See Also