[Tutorial & Sample] Using Parameter Alias to simplify the OData URL


Are you suffering from typing complex parameter values in URL? Or even make it worse you need to type it more than once?

To solve this problem, now Microsoft.OData.Core.dll 6.0 supports parameter alias in request URL, such as: ~/People?$filter=LastName eq @name and contains(Description, @name)&@name=’Bob’

It is implemented by introducing a new class: ParameterAliasNode and its base class is SingleValueNode. The alias (@name) is parsed into a ParameterAliasNode.

Note: This blog assumes that you have writing ODL server side code experience.

But how to leverage this feature? Just 3 steps:

1. Create an instance of ODataUriParser as normal:

2. Update the node visitor to support ParameterAlliasNode:

3. Call the visitor to translate the node tree into expression:

Then execute the Linq Express as normal, that’s it.


Discussion is closed.

Feedback usabilla icon