Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WebService - DataBaseSetKey Problem
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01253007
Message ID:
01253161
Vues:
25
Thomas,

>I have a Webservice, that is used from several customers. Each customer has its own Database or in mm its own DatabaseSet.
>
>When the webservice gets an request, I switch the DatabaseSetKey of the DatabaseMgr to the DatabaseSet of the Customer:
>mmAppBase.DatabaseMgr.DatabaseSetKey = customerX
>
>Now getting more and more simultaneos requests I run into the problem that sometimes CustomerX is getting data from customerY.
>
>What I think is happening is, that I set the global
>mmAppBase.DatabaseMgr.DatabaseSetKey property and before the business object is getting the data from CustomerX, customerY is requesting data and switches mmAppBase.DatabaseMgr.DatabaseSetKey to CustomerY.
>
>My question now can this be true?
>Any idea how to override GetDataAccessObject() in the business objects, that dao.DatabaseSetKey = mmAppBase.DatabaseMgr.DatabaseSetKey;
>is not getting the DatabaseSetKey from mmAppBase.DatabaseMgr?
>Any other idea how to solve this problem?

Switching dynamically to different customers works well "as is" in a Windows Forms application because there is only one copy of the DatabaseManager per application. In a web scenario, you need to do something a little different.

Typically, other MM .NET developers have set up an architecture where they pass the Customer ID to the constructor of the business object, and they don't create a default, parameterless constructor so developers are forced to pass the customer ID. You can then use the customer id as the database set key and use it to reliably retrieve the connection string from the app.config file or whereever you store it.

In the next release of MM .NET there are overloads of mmDatabaseManager's GetConnection() and GetDataAccessClassName() that accept a database set key in addition to a database key. If you contact me via private e-mail I can get you this code sooner than later. Basically, you can subclass mmDatabaseManager and override the existing GetConnection() and GetDataAccessClassName() methods and add the two new overloads. You can then override the Factory method that creates the database manager so it instantiates your custom database manager instead.

Best Regards,


Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform