Let’s see how to build and use the above types in function.
CLR Model
First of all, we create the following CLR classes as our model:
Build Edm Model
Now, we can build the Edm Model as:
where, BuildFunction() is a helper function in which functions can be built.
Primitive and Collection of Primitive parameter
Configuration
In BuildFunction(), we can configure a function with Primitive and collection of Primitive parameters:
Routing
In the CustomersController, add the following method:
Request Samples
We can invoke the function as:
Enum and Collection of Enum parameter
Configuration
In BuildFunction(), we can configure a function with Enum and collection of Enum parameters:
Routing
In the CustomersController, add the following method :
Request Samples
We can invoke the Enum function as:
Complex and Collection of Complex parameter
Configuration
In BuildFunction(), we can configure a function with Complex and collection of Complex parameters:
Routing
In the CustomersController, add the following method :
Request Samples
We can invoke the complex function as:
Entity and Collection of Entity parameter
Configuration
In BuildFunction(), we can configure a function with Entity and collection of Entity parameters:
It’s better to call EntityParameter<T> and CollectionEntityParameter<T> to define entity and collection of entity parameter.
Routing
In the CustomersController, add the following method :
Request Samples
We can invoke the entity function as:
However, only parameter alias is supported for entity.
Entity Reference and collection of Entity Reference parameter
In fact, we can’t build a function with entity reference as parameter. However, we can call the function with entity parameter using entity reference value. So, without any change for the EntityFunction, we can call as:
FromODataUri
‘[FromODataUri]’ is mandatory for complex, entity and all collection. However, it is optional for Primitive & Enum. But for string primitive type, the value will contain single quotes without ‘[FromODataUri]’.
Thanks.
For un-typed scenario, please refer to untyped page.