Parameter Element (CSDL)

The Parameter element in conceptual schema definition language (CSDL) can be a child of the FunctionImport element or the Function element.

FunctionImport Element Application

A Parameter element (as a child of the FunctionImport element) is used to define input and output parameters for function imports that are declared in CSDL.

The Parameter 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 Parameter element.

Attribute Name Is Required Value

Name

Yes

The name of the parameter.

Type

Yes

The parameter type. The value must be an EDMSimpleType or a complex type that is within the scope of the model. For more information, see Conceptual Model Types (CSDL).

Mode

No

In, Out, or InOut depending on whether the parameter is an input, output, or input/output parameter.

MaxLength

No

The maximum allowed length of the parameter.

Precision

No

The precision of the parameter.

Scale

No

The scale of the parameter.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the Parameter 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 FunctionImport element with one Parameter child element. The function accepts one input parameter and returns a collection of entity types.

<FunctionImport Name="GetStudentGrades" 
                EntitySet="StudentGrade" 
                ReturnType="Collection(SchoolModel.StudentGrade)">
       <Parameter Name="StudentID" Mode="In" Type="Int32" />
</FunctionImport>

Function Element Application

A Parameter element (as a child of the Function element) defines parameters for functions that are defined or declared in a conceptual model.

The Parameter element can have the following child elements (in the order listed):

Note

Only one of the CollectionType, ReferenceType, or RowType elements can be a child element of a Property element.

Note

Annotation elements must appear after all other child elements. Annotation elements are only allowed in conceptual models for applications that target the .NET Framework version 4 or later. The XML namespace for such models is https://schemas.microsoft.com/ado/2008/09/edm.

Applicable Attributes

The following table describes the attributes that can be applied to the Parameter element.

Attribute Name Is Required Value

Name

Yes

The name of the parameter.

Type

No

The parameter type. A parameter can be any of the following types (or collections of these types):

  • EdmSimpleType

  • entity type

  • complex type

  • row type

  • reference type

For more information about these types, see Conceptual Model Types (CSDL).

Nullable

No

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

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 Parameter 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 Function element that uses one Parameter child element to define a function parameter.

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

See Also

Concepts

Entity Framework Overview
CSDL Specification
EntityContainer Element (CSDL)

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools
How to: Import a Stored Procedure
How to: Define Custom Functions in the Conceptual Model