GlobalContext value from Silverlight client to DAL

GlobalContext value from Silverlight client to DAL

Old forum URL: forums.lhotka.net/forums/t/12004.aspx


hanspret posted on Wednesday, June 05, 2013

Hi, In our application we would like to allow the user to choose a database via a dropdown box when he/she logs in.

The application is a Silverlight application. Because the architecture of Silverlight is client/server we need to get the database name from the client with each request to query or manipulate the right database in the DAL.

I can do this by changing my factory methods like below and pass the database right through to the DAL:

public static void getCustomers(string Database, ...

But we have a lot of factory methods and will take us forever to change each one of them and passing the database to the DAL.

I thought that maybe I can use the Csla.ApplicationContext.GlobalContext to store the database value at client side (Silverlight) and then access the GlobalContext in my DAL.

I have done this on my local machine and it actually works. I have tested it with multiple clients (browser instances) on my local PC and with each request it shows the database selected at client in the DAL.

But when I deployed it to a remote server and tried to access it from my PC I got the error "Object not set to an instance...."

What will be the best solution be to implement the multiple database function?

Remember that I need to get the database name also with Inserts, Updates and Deletes.

 

P.S. I found this question, but it explains how to send a value via GlobalContext from Server to Silverlight.

 

JonnyBee replied on Wednesday, June 05, 2013

Hi,

My general recommendation would be to use the ApplicationContext.ClientContext rather than the GlobalContext as the GlobalContext is also included in the response. 

The big question is why you get the exception. Do you have the stack trace? 

Copyright (c) Marimer LLC