Hi,
I’m looking for a way to indicate the connection to use in the server, from the client. For years, ever since I started using DA, I’ve used the BeforeAcquireConnection method to use the session data to set the connection:
private void DataService_BeforeAcquireConnection(DataAbstractService sender, BeforeAcquireConnectionEventArgs e)
{
e.ConnectionName = (string)Session["ConnectionName"];;
}
This works fine most of the time, except when I need to use multiple connections. In this case, I need to do something like:
remoteService.SetWorkingCompany("MyCompany1"); // Set the connnection name in the session
var data = ldaDataService.GetTable<MyTable>().ToList();
remoteService.SetWorkingCompany("MyCompany2"); // Set the connnection name in the session
var data = ldaDataService.GetTable<MyTable>().ToList();
This means I need to do an extra remote call before I can get the data. I want to start sending the connection info from the client, in the remote data adapter call, perhaps using a parameter in the DataRequestCall. For example, something like:
ldaDataService.DataRequestCall.ParameterByName("Company_GUID").Value = "xxx";
var data = ldaDataService.GetTable<MyTable>().ToList();
and then create an override in my data service that would get this parameter, and based on this parameter set the connection to be used in the call. I would also check access restrictions to make sure the client has access to that connection, which now is only made during login, but with this change, it would have to be made on every call to the new GetData method. But my main concern is how to send this connection info in the DataRequestCall to avoid the extra remote call before getting the data.
Could you provide some pointers or perhaps a quick example on how to achieve this?
Thanks,
Arturo.