Articles → Light Switch 2011 → Queries In Light Switch 2011
Queries In Light Switch 2011
Software Requirement
- Visual studio 2010 is installed on your machine.
- Visual Studio 2010 service pack 1 is installed on your machine.
- Microsoft Visual Studio Light switch 2011 is installed on your machine.
- Silverlight runtime version 4 or 5 is installed on your machine
Prerequisite Knowledge
- How to create project using visual studio?
- How to create screens in lightswitch?
- How to create tables in lightswitch?
What Is A Query?
Steps Of Execution
- Create a new project
- Create a new table
- Add data in the table
- Add query on the table
- Add parameters in query
- Bind grid with query
- Bind drop down with query
Create A New Project
Click to Enlarge
Create A New Table
Click to Enlarge
Add Data In The Table
Click to Enlarge
Add Query On The Table
- Right click on the table and click on Add Query.
Click to Enlarge
- A designer screen will open and a new query Query1 will be created. You can rename the query by double click on it
Click to Enlarge
Add Parameters In Query
- Click on Add Filter option
- A new row will be added from which you can add where condition for the query.
Click to Enlarge
- In the first column we have a drop down having 2 values i.e. where and where not.
- Second column contains the list of all fields in a table on which filter can be applied. You can select any of the field.
- Third column is a drop down which contains the list of comparison operators like equal to, not equal to and so on.
- Fourth column is for the type of query parameter. It can be a literal i.e. hard coded string, a property or a parameter which can be set at run time.
- Fifth column is the value of query parameter.
Click to Enlarge
Click to Enlarge
Click to Enlarge
- Click on the parameter and press F4
- Property window will be opened on the right hand side.
- Check the option ‘Is Optional’
Click to Enlarge
Bind Grid With Query
- First of all add a new screen of type Editable grid screen.
- Select query as data source of the screen. See the screen shot below
Click to Enlarge
- Click Ok
Click to Enlarge
Click to Enlarge
Bind Drop Down With Query
Click to Enlarge
Click to Enlarge
Click to Enlarge