Provide an OData Source Query at Runtime
Applies to: SQL Server SSIS Integration Runtime in Azure Data Factory
You can modify the OData Source query at runtime by adding an expression to the [OData Source].[Query] property of the Data Flow task.
The columns returned have to be the same columns that were returned at design time; otherwise, you get an error when the package is executed. Be sure to specify the same columns (in the same order) when using the $select query option. A safer alternative to using the $select option is to deselect the columns you don't want directly from the Source Component UI.
There are a few different ways of dynamically setting the query value at runtime. Here are some of the more common methods.
Provide the query as a parameter
The following procedure shows how to expose the query used by an OData Source component as a parameter of the package.
Right-click on the Data Flow task and select the Parameterize... option.
In the Parameterize dialog, select [<Name of the OData Source Component>].[Query] for Property.
Choose whether to create new parameter or use an existing parameter.
If you select Create new parameter:
Enter name and description for the parameter.
Specify default value for the parameter.
Specify the scope (package or project) for the parameter.
Specify whether the parameter is required or not
Click OK to close the dialog box.
Provide the query with an expression
This method is useful when you want to dynamically construct the query string at runtime.
Select the Data Flow Task that contains your OData Source.
In the Properties window, highlight the Expressions property.
Click the ... (ellipsis) button to bring up the Property Expressions Editor.
Select the [OData Source].[Query] property.
Click the ... (ellipsis) button for Expression.
Enter the expression.
Click OK.
Note
When you use this approach, you have to ensure that the values you set are properly URL encoded. When receiving values from user input (for example, setting individual query option values from a parameter), you must ensure that the values are validated to avoid potential SQL injection-type attacks.