Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i'm using C# (WPF) in visual studio 2010 ...

i want write a application that normal users make daily record in databse, for this normal users, i need embeded database like "SQL Compact", and for special user that merge normal users records, i need a faster database like "MS SQL" or "MySQL".

and now, any idea how to have ability to changing between database system (like : SQL Compact, MS SQL, MySQL or ...) in my application ?


ps: sorry for bad english ^_^
Posted
Updated 14-Feb-10 20:32pm
v2

1 solution

Create a data access layer. For example, create an interface called IRepository with methods like GetCustomers() and GetCustomerByID(). Have one repository, MsSqlRepository, implement IRepository with MS SQL specific code. Then have another repository, MySqlRepository, implement IRepository with MySQL specific code. And so on, for each database provider.

Have all your code expect an IRepository. Then, whenever you need to create an actual instance of IRepository, initialize one of the classes that implements that interface (MsSqlRepository or MySqlRepository).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900