Use the DataServiceQuery universal class to retrieve the service's object collection. This class is a request to the service that retrieves the collection of a specific type of entities.
Create a context object instance of the Creatio application environment to execute a request to EntityDataService.svc.
The examples in this article will use the forms authentication.
To implement the forms authentication:
- Create a LoginClass class.
- Implement the authServiceUri (a string that requests the Login method of the AuthService.svc authentication service) and AuthCookie (Creatio's authentication cookies) fields.
- Implement the TryLogin(string userName, string userPassword) method that authenticates the user and saves the server's response to the AuthCookie field.
-
Implement the OnSendingRequestCookie(object sender, SendingRequestEventArgs e) method that will be called in response to an event of the SendingRequest context instance (creating a new HttpWebRequest instance).
The OnSendingRequestCookie method authenticates the user and adds the cookies received in response to the data request.
There are several ways to execute the service request:
- A LINQ request to the named DataServiceQuery object received from the service context.
- Implicit enumeration of the DataServiceQuery object received from the service context.
- Explicit call of the Execute method of the DataServiceQuery object. Call the BeginExecute method for asynchronous execution.