D
Dino Buljubasic
Hi,
How can I make my application work with SQL Server, Oracle, MySql,
etc?
_dino_
How can I make my application work with SQL Server, Oracle, MySql,
etc?
_dino_
Sahil said:Thats a hard goal to acheive.
You can try using something similar to the Dbproviderfactory model in
.NET 2.0 - but even then you are stuck with 70% of database specific
code - i.e. PLSQL vs. TSQL.
You have to segregate everything into an as thin data layer as
possible and then write different datalayers for different .NEt data
providers - thats about the only way.
for you which is usable with a lot of different databases (like an
O/R mapper)
Sahil Malik said:Does your O/R Mapper generate db specific queries without having to do any
special treatment for different databases?
Sahil said:Does your O/R Mapper generate db specific queries without having to
do any special treatment for different databases? If so "WOW". It is
quite a hard goal to acheive though - just that you've done all the
hardwork.
- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------
------
in >> .NET 2.0 - but even then you are stuck with 70% of database
specific >> code - i.e. PLSQL vs. TSQL.data >> providers - thats about the only way.
Yes. And in the upcoming 1.0.2005.1, you can even define type
converters, so Oracle NUMBER(1,0) (or any other type, just write a few
lines of code) for example can be mapped onto bool, transparently, so
you can have a single code base targeting a set of entities, which have
for example some boolean fields, and on Sqlserver they're mapped onto
bitfields, and on Oracle they're mapped onto NUMBER(1,0). (you can map
any.NET type onto any db type )
. This even works cross entity actions, so fetch an entity from
sqlserver, use it and save it into oracle or vice versa (or other db).
It's not that hard really: an O/R mapper knows the meta-data, and the
object state. So with a per-db SQL engine, you can generate any SQL
targeting any db, as long as you have an SQL engine for that database.
Unless you want to use stored procedures of course
FB