Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

  1. Open a query by double clicking it in the Solution Explorer.

    The query designer opens.

  2. 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.

  3. 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:

General Methods

Description

<QueryName>_PreProcessQuery()

Called when the query is being formed. Enables you to further customize a query. Runs on the server.

<QueryName>_Executing()

Called just before executing the query. Runs on the server.

<QueryName>_Executed()

Called just after successfully executing the query. Runs on the server.

<QueryName>_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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft