views:

28

answers:

2

I am creating a quick and dirty prototype (C#) of an object-relational mapping tool. I would like to support at least two kinds of databases - one will be Microsoft SQL Server 2005/2008 and the other most probably MySQL.

Is there any way to use a single data base access mechanism for both database engines and what would it be?

Of course, I know that there will be differences in SQL query syntax, but in my case it is not that important - I'll use a tool to generate SQL queries which suit the certain db engine and user will be able to optimize those SQL queries.

The main idea is to have as flexible data provider solution as possible. Can it be done or not and how can it be done easier? Note that I am not using this for a production system, just for a prototype, but still I'm curious how it is achieved in production OR/M tools - are they using completely separate access mechanism for each data provider or there are something common? And are they using DataReaders or there is some more appropriate way to retrieve data if I intend to transform data to business objects?

Thanks for any ideas, links etc.

+1  A: 

I recommend nhibernate - which does what you want I think.

nhforge

Brad Langhorst
Thanks, I am familiar with nHibernate, but this time I myself am trying to build a prototype which does something similar to nHibernate. I could look into the source code of some nHibernate tool, but I thought that someone experienced will give a quick reply how it could be done easier, considering that nHibernate is a full-blown production tool but I need a solution for a simple prototype..
Martin
A: 

Ok, I found it: http://www.15seconds.com/issue/040127.htm

the solution is to use IDbxxx or Dbxxx as described in msdn.microsoft.com/en-us/library/ms379620(VS.80).aspx

Now I can specify only once what kind of DataProvider I use and then just use Db/IDb everywhere else.

Martin