# Events

This topic will go through the event model exposed by **RadDataServiceDataSource** and the purposes for which each event can be used.

* [LoadingData](https://www.telerik.com/products/wpf/documentation/controls/raddataservicedatasource/events#loadingdata)
* [LoadedData](https://www.telerik.com/products/wpf/documentation/controls/raddataservicedatasource/events#loadeddata)
* [SubmittingChanges](https://www.telerik.com/products/wpf/documentation/controls/raddataservicedatasource/events#submittingchanges)
* [SubmittedChanges](https://www.telerik.com/products/wpf/documentation/controls/raddataservicedatasource/events#submittedchanges)

## LoadingData

At this stage the data loading operation can be canceled, as the event is raised before the loading is to be executed. Also, the **LoadingDataEventArgs** event arguments provide information regarding the generated query which can be modified as well.

* **Cancel**: Boolean property that gets or sets the value whether the event should be canceled or not.
* **Query**: Property of type [DataServiceQuery](https://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicequery\(v=vs.110\).aspx) which can be fetched and modified.

## LoadedData

This event provides various information and options regarding the processed query. The **LoadedDataEventArgs** event arguments inherit from the [AsyncCompletedEventArgs](https://msdn.microsoft.com/en-us/library/system.componentmodel.asynccompletedeventargs\(v=vs.110\).aspx) and expose the properties listed below.

* **Cancelled**: Boolean property that provides information whether an asynchronous operation has been canceled.
* **Entities**: Gets all top-level entities that were loaded.
* **Error**: Provides information which particular error occurred during the operation.
* **HasError**: Boolean property giving information whether the operation has failed.
* **IsErrorHandled**: When there is an error it can be handled through the **MarkErrorAsHandled** method of the event arguments. In such case the property will return **True**. Otherwise, it will return **False**.
* **TotalEntityCount**: Gets the total entity count for the load operation.
* **UserState**: Gets the unique identifier for the asynchronous task.

## SubmittingChanges

Through this event the submitting of the made changes can be canceled. Also, the [SaveChangesOptions](https://msdn.microsoft.com/en-us/library/system.data.services.client.savechangesoptions\(v=vs.110\).aspx) can be modified. The event arguments are of type **DataServiceSubmittingChangesEventArgs** which expose the following properties.

* **Cancel**: boolean property that gets or sets the value whether the event should be canceled or not.
* **SaveChangesOptions**: Gets or sets the save changes options.

## SubmittedChanges

The **DataServiceSubmittedChangesEventArgs** also inherit from the [AsyncCompletedEventArgs](https://msdn.microsoft.com/en-us/library/system.componentmodel.asynccompletedeventargs\(v=vs.110\).aspx). As an addition to them the **DataServiceResponse**, **HasError** and **IsErrorHandled** properties are added as well the **MarkErrorAsHandled** method.

* **Cancelled**: Boolean property that provides information whether an asynchronous operation has been canceled.
* **DataServiceResponse**: Gets the response from the service.
* **Error**: Provides information which particular error occurred during the operation.
* **HasError**: Boolean property giving information whether the operation has failed.
* **IsErrorHandled**: When there is an error it can be handled through the **MarkErrorAsHandled** method of the event arguments. In such case the property will return **True**. Otherwise, it will return **False**.
* **UserState**: Gets the unique identifier for the asynchronous task.

## See Also

* [The DataServiceContext](https://www.telerik.com/products/wpf/documentation/controls/raddataservicedatasource/loading/the-dataservicecontext)
* [The DataServiceQuery](https://www.telerik.com/products/wpf/documentation/controls/raddataservicedatasource/loading/the-dataservicequery)
