How to call stored procedures to suit different database

Posts   
 
    
xc_lw2000
User
Posts: 48
Joined: 12-Dec-2006
# Posted on: 20-Oct-2011 05:56:40   

I want my application face to different database,so I create mulitple databaseSpecific project and a class DatabaseProvider to check app.config file and determine which DataAccessAdapter to use at runtime.

But when call stored procedures,I don't know how to write my code to achive that do not modify my code,just modify the app.config,It will call the sp in correct database.

Since ActionProcedures and RetrievalProcedures are all static class and no base class,so when I swich database,I must modify my code to use different assmbly

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 20-Oct-2011 10:18:25   

You may do the following: - For each DBSpecific project create a class that wraps the ActionProcedures and RetrievalProcedures. (Composition). - You may define an Interface or base class for them. - Switch between these classes in the DatabaseProvider.