[Mono-list] [Mono-dev] SqlCeServer on mono
Robert Jordan
robertj at gmx.net
Wed May 16 10:10:25 EDT 2007
Manuel de la Pena wrote:
>
> The problem is that for some reason the people a Microsoft decided to
> use a completely new namespace for SqlCe server. That is, they have
> implemented a SqlCeDataReader, SqlCeCommand etc...
All DB providers are implemented using this scheme.
> My question is the following.. If someone has already created an
> application using the Visual studio tools and have made some code such as
>
> public void Method(){
>
> SqlCeConnection conn = new SqlCeConnection(connectionString);
> SdlCeCommand sql = new SqlCeCommand("SELECT * FROM table", conn);
>
> SqlCeDataReader dataReader = sql.ExecuteReader();
>
> while(dataReader.Read())
> {
> //blah blah blah
> }
>
> }
>
> Should we allow them to compile the code with out changing the code, or
> on the other hand should you force them to use the more correct code:
>
> public void Method(){
>
> IDbConnection conn = new SqlCeConnection(connectionString);
> IDbCommand sql = new SqlCeCommand("SELECT * FROM table", conn);
>
> IDataReader dataReader = sql.ExecuteReader();
>
> while(dataReader.Read())
> {
> //blah blah blah
> }
>
> }
>
> We all agree that the second code is a more correct one since it allows
> to easily change of db technology, but we can also agree that there are
> the hell of a lot of programmers that do not use the interfaces and use
> the objects instead. What I'm proposing is to create the name space to
> avoid making people change their code when compiling on linux, at the
> end of the day that would make the switch easier for programmers,
> wouldn't it??
I don't agree. Broken design has to be fixed in code rather than
with runtime hacks.
The recommended way is to employ a provider factory:
http://www.mono-project.com/Provider_Factory
Robert
More information about the Mono-list
mailing list