This is a migrated thread and some comments may be shown as answers.

Changing The Application DataProvider from SQL to Oracle

1 Answer 56 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mohamed
Top achievements
Rank 1
Mohamed asked on 10 Mar 2014, 09:46 AM
Hi everybody
I built web project and used Telerik DataAccess tool to build the model (DAL), i built model first and then create the database tables on SQL Server and then Oracle as well
my problem is, i want the same model project dll to serve both SQL and Oracle DBs by just changing the connection string in web.config and change the data provider to be Oracle or SQL without having to rebuild the data model project every time 
Simply i want to publish only one project to be able to connect to both Oracle and SQL by just changing configurations 

1 Answer, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 12 Mar 2014, 04:48 PM
Hello Mohamed,

You can achieve this behavior using Telerik Data Access following next steps:

1) You should have two connection strings in the app/web config file.
2) Extend the context class with a partial class, where you should create a new constructor.
3) You should have two static methods which returns BackendConfiguration - one for Oracle and one for SQL Server and pass this configuration when you call the constructor.

The new partial class should look like:
01.public partial class EntitiesModel
02.{
03.    public EntitiesModel(string connection, BackendConfiguration backendConfiguration)
04.        : base(connection, backendConfiguration, metadataSource)
05.    { }
06. 
07.    public static BackendConfiguration GetOracleBackendConfiguration()
08.    {
09.        BackendConfiguration backend = new BackendConfiguration();
10.        backend.Backend = "oracle";
11.        backend.ProviderName = "Oracle.DataAccess.Client";
12.        backend.Runtime.ReturnNullForRowNotFound = true;
13.        ...           
14.        return backend;
15.    }
16. 
17.    public static BackendConfiguration GetSqlServerBackendConfiguration()
18.    {
19.        BackendConfiguration backend = new BackendConfiguration();
20.        backend.Backend = "mssql";
21.        backend.ProviderName = "System.Data.SqlClient";
22.        backend.Runtime.ReturnNullForRowNotFound = true;
23.        ...
24.        return backend;
25.    }
26.}

I hope that helps.

Regards,
Boris Georgiev
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Data Access Free Edition
Asked by
Mohamed
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Share this question
or