Here we will see how to add a query on a table in LightSwitch using Visual Studio 2012.
This article describes how to add a query in a table.
Step 1
Open the Solution Explorer.
Step 2
In the Solution Explorer, right-click on the Server and choose "Add Table".
Step 3
The table appears.
Step 4
In the Solution Explorer, right-click on the Screens and choose "Add Screen".
Step 5
The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, under screen information, choose "Employee" under the screen data and provide a name to the Screen and click the "OK" button.
The screen designer appears.
Step 6
Press F5 to run the application.
Step 7
Now stop debugging and right-click on the table and choose "Add Query".
The Query Screen Designer will open. Right-click on the query and choose "Rename" to rename the query.
Step 8
There are two ways of adding parameters to a Query.
1: Go to "Add Query Element" in the top of the query designer, a drop down list will appear, choose "Add Filter".
2: Another way is, in the query designer, directly click on "Add Filter".
Either way, a new row will be added by which you can add a query.
The filter consists of the following 5 columns:
1: The first column consists of two values in a drop down format (in other words where and where not).
2: The second column consists of a list of all the records that belong to a table on which the filter can be applied. The user can select any one field from the given list.
3: The third column consists of the list of all comparison operators. Here the user can also select an operator from the list.
4: The fourth column consists of the query parameter type.
5: The fifth column consists of the query parameter value.
To add a parameter, select parameter under the type of query parameter and select "Add New" in the last column.
Once we have selected the "Add New" option, in the parameter section a new row will be added automatically as shown below.
Suppose we want to make the parameter optional. To do that first select the parameter option and then go to the property window.
Mark the "IsOptional" checkbox checked.