Extending devart's oracle factory and connection classes

Extending devart's oracle factory and connection classes

Postby ramana.bhavaraju » Fri 24 Feb 2012 10:09

Hi,

I am trying to extend devart's OracleProviderFactory and OracleConnection classes, as i need to provide my own implementation on how i handle closing of connections (due to the way we do multi threading in the application) by overriding the close method of the connection class. So can you please let me know how do i register my custom factory to the Dbfactories collection, as it looks like my factory class is not getting loaded with the providername = "customerassemblyname"in the connection string.

Thanks.
Ramana
ramana.bhavaraju
 
Posts: 14
Joined: Thu 28 Jan 2010 17:13

Postby Pinturiccio » Thu 01 Mar 2012 14:30

You have to add your provider to the application config file (App.config - local settings) or to the machine.config file (global settings).
Let's consider that you have an assembly "Customer.dll, version=1.0.0.0, Culture=neutral, PublicKeyToken=e2bf3be94404398e" with a class:
Code: Select all
public class CustomerProviderFactory : OracleProviderFactory
{
    public new static CustomerProviderFactory Instance = new CustomerProviderFactory();
}

So you have to add the foolowing information to a config file (App.config or machine.config):
Code: Select all
<system.data>
  <DbProviderFactories>
    <remove invariant="Customer" />
    <add name="Customer Provider" invariant="Customer"
     description="New Customer Provider"
     type="Customer.CustomerProviderFactory, Customer,
       Version=1.0.0.0, Culture=neutral, PublicKeyToken=e2bf3be94404398e" />
  </DbProviderFactories>
</system.data>

Then you can create and use your provider:
Code: Select all
DbProviderFactory fact = DbProviderFactories.GetFactory("Customer");
DbConnection conn = fact.CreateConnection();
conn.Open();
conn.Close();
Pinturiccio
Devart Team
 
Posts: 1849
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for Oracle