Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data Access object creation in mmBusinessObject is fragile
Message
From
04/05/2007 00:20:32
Walter Nicholls
Cornerstone Software Ltd
Auckland, New Zealand
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Data Access object creation in mmBusinessObject is fragile
Miscellaneous
Thread ID:
01222394
Message ID:
01222394
Views:
84
Hi Kevin.
(Please let me know if you prefer bug reports sent by another channel .. I'm just using this one because, well, I have been <g>)

MM.NET version 2.4

Observed: If a DataAccessClass is misspelt in app.config, the code assumes it is DataAccessSql
Expected: DataAccessSql should only be assumed if a class is NOT specified (or String.Empty). If the class is not recognized then an exception should be thrown

Example: (from app.config)
  <add key="MYOB\DataAccessClass" value="DataAccessOldDb" />
(Look closely!)

The culprit code, in mmBusinessObject.cs method CreateDataAccessObject()
switch (dataAccessClassName)
{
 ....
    case "dataaccesssql":
    default:
       dao = new mmDataAccessSql();
}
Expect something like...
....
    case "dataaccesssql":
    case String.Empty:
       dao = new mmDataAccessSql();
       break;
    default:
       throw new ErrorInConfigFileException( "Don't understand class.." );
Also while I think of it, seems strange that this code is in mmBusinessObject, might be sensible to delegate this to mmAppBase.Factory.CreateDataAccessObject(classname) which would theoretically enable bizobj layer to be database-independent, if I were to implement say CreateDataAccessPostgres() in the factory class - although in practice don't know how often that would be achieved!

Incidentally, in my particular example after fixing this config file, I get
The .Net Framework Data Provider for OLEDB (System.Data.OleDb) does not support the Microsoft OLE DB Provider for ODBC Drivers (MSDASQL). Use the .Net Framework Data Provider for ODBC (System.Data.Odbc).
So I'm going to have to implement a DataAccessOdbc class and override ABusinessObject.CreateDataAccessObject() anyway ...
I hope this isn't going to take too long... the existing .cs files are 1200 lines long.

Cheers,
Walter
Next
Reply
Map
View

Click here to load this message in the networking platform