Using the sane DAL (Data Access Layer) on a desktop and Windows Mobile System, with diferent databases clients

Hi experts.

I'm developping an application that will run on both desktop and Windows Mobile platform. Since the application is the same, I'm developing it in a 3 tier project. The Data tier and the Business Tier will be the same on both applications. Only the presentation tier will be different.

My DAL was built in a way that we can connect to an Oracle Database (System.Data.OracleClient) when used by the Desktop app and to an SqlCE database, when using Windows Mobile.

The problem is that the DAL references both Oracle and SqlCE libraries when loaded and, to make it work on Desktop I need to install SqlCE, that will be never used in this way. Worse then this, when the DAL is loaded on a Windows mobile, they also needs to load OracleClient, that will never be available.

So, is there any way to load this references on runtime, without performance hits, and without loosing the connection pool that exists on OracleClient, or will I need to develop 2 DALs, one to each case described?

Thanks a lot.

regisdanielAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Vikram Singh SainiConnect With a Mentor Software Engineer cum AD DeveloperCommented:
Hi,

There are two things:

(1) No, you can  not add reference at runtime.  Adding  reference creates  several classes that provide you different methods and properties; those  classes need to be compiled before they can be used.
 
(2) But Yes, the same can be made possible by Reflection. You should have look on link:
http://www.codeguru.com/csharp/csharp/cs_syntax/reflection/article.php/c5881

Regards,
VSS
0
 
waheedkConnect With a Mentor Commented:
you need to develop two different DALs each for a DBMS, and use a DAL factory for loading the required DAL.
0
 
regisdanielAuthor Commented:
Hi VSS and Waheedk, thanks for your help.

VSS, do you know if the Connection Pool functionality will be preserved if I use reflection, as you suggest ?

Waheedk, the solution you provided, using a Database Factory, also uses Reflection to Load the correct DAL?

Thanks.
0
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
Hi,

As far I know about Connection Pooling it is the concept that is attached with website. For e.g., if your website which is been deployed on IIS server, then if your application is connecting to database, and you have made Connection Pooling to true, then in that case the asp worker process is there to maintain connection pooling, & it is preserved until any type of modifcations is not done in connectionString be it in ordering or in the data within it.

However after a specified period of time, if connections are not used from connection pool they are destroyed automatically. So I think there should be no issues while using reflection.

Regards,
VSS
0
 
PJBXConnect With a Mentor Commented:
I think you should have separate DALs.  How much data do you plan on loading? I would be concerned about SQLCE and memory. However, if you have to, the Entity Framework 4 might be an option for both platforms.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.