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.
The following table lists the query events that can be handled by your application:
Called when the query is being formed. Enables you to further customize a query. Runs on the server.
Called just before executing the query. Runs on the server.
Called just after successfully executing the query. Runs on the server.
Called after a query fails to run. Runs on the server.
Called prior to executing the query in order to check permissions for the current user. Runs on the server.