How to: Handle Query Events
You can customize your application by writing code that runs when certain query-related events occur. For example, you can extend a query by adding code to an event that occurs when the query is being processed by LightSwitch.
To handle a query event
Open a query by double clicking it in the Solution Explorer.
The query designer opens.
Click the arrow next to the Write Code button at the top of the Query Designer and select the method that you want to override. The methods that can be handled by your application appear in the table below.
The Code Editor opens.
Place your cursor in the method that was just created and type the code that you want to run when the event occurs.
List of Query Events
The following table lists the query events that can be handled by your application:
General Methods |
Description |
---|---|
<QueryName>_PreProcessQuery() |
Called when the query is being formed. Enables you to further customize a query. Runs on the server. |
Query_Executing() |
Called just before executing the query. Runs on the server. |
Query_Executed() |
Called just after successfully executing the query. Runs on the server. |
Query_ExecuteFailed() |
Called after a query fails to run. Runs on the server. |
Security Methods |
Description |
---|---|
<QueryName>_CanExecute() |
Called prior to executing the query in order to check permissions for the current user. Runs on the server. |
See Also
Tasks
How to: Handle Silverlight Screen Events