More on Enterprise Library (EntLib), ODP.NET and type mapping

· September 4, 2008

The last time I wrote about this I was a bit too fast to get all the intricate details down. One of those details blew up in my face today.

The main reason for why it took me the better part of the afternoon to sort out had to do with some really confusing name-setting. Here is was confused me;

  • the namespace System.Data.Oracle Microsoft has provided a implementation of a Oracle client provider. Keyword: Microsoft -this implementation doesn’t contain all the functionality in Oracle databases.
  • cause of that Oracle has given us the Oracle.DataAccess.Client or ODP.NET for short. In this you’ll have all the things you’ll need.

Both of these inherits from the generic DbCommand (and uses the same name for almost everything) and can hence be converted into DbCommand but not into each other (of course - but this took me about 1,5 hours to grasp, since the both are called OracleCommand but are in separate namespaces…)

So far so good - go with ODP.NET to get the details and probably the best implementation of the data provider for .NET, I’ve got it.

But I use the Enterprise Library Data Access Block (4.0) - will not ODP.NET become a problem, I said to myself. Enterprise Library doesn’t know anything about ODP.NET and only uses DbCommand internally.

Well no, because as you easily can use any data provider in the config-file (ConnectionString-section) AND the Oracle.DataAccess.OracleCommand inherits from DbCommand you’re home free.

In fact you’ll get the best of two worlds. When you need the nitty gritty details (like CollectionType / Associative Arrays) you can create a OracleParameter or Command and send it as parameter to your command. When the standard DbCommand is enough you’ll use it and it’s features.

So I simply removed some of the features from my earlier post such as the OracleDatabase (I only use the generic stuff) and kept other things such as the methods to create OracleParameters, since I’ll need some details found in the OracleParameter class.

I works so nicely. A big thank you to Jens for pointing me in the right direction when I was lost in the inheritance structures.

Twitter, Facebook